4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OutSystemsのDecimalToInteger, TextToIntegerの挙動を調べてみた

4
Posted at

やったこと

OutSystemsのDecimalToInteger, TextToIntegerの挙動を調べてみました。

きっかけ

Twitterで、

を見かけて、OutSystemsのDecimalToInteger, TextToIntegerはどのような変換をするんだろうと思ったためです。

利用したOutSystemsのバージョン

  • サーバー:Version 11.0.212.0
  • Service Studio:11.6.2

結果

Action 入力 出力 補足
DecimalToInteger 2 2
1.1 1
1.5 2 四捨五入されている
1.9 2 四捨五入されている
.1 0
0.000001 0 Twitterのケースは問題なし
0.0000001 0 Twitterのケースは問題なし
+1.1 1
-1.1 -1
4/3 - Decimal expected!エラーになった
1,234 - Decimal expected!エラーになった *1
1.23e+3 - Decimal expected!エラーになった
1.23e-3 - Decimal expected!エラーになった
0x3C1 - Decimal expected!エラーになった
TextToInteger 2 2
1.1 0 小数を受け付けない模様
1.5 0 小数を受け付けない模様
1.9 0 小数を受け付けない模様
.1 0 小数を受け付けない模様
0.000001 0 小数を受け付けない模様
0.0000001 0 小数を受け付けない模様
+1.1 0 小数を受け付けない模様
-1.1 0 小数を受け付けない模様
4/3 0 分数もダメ
1,234 0 カンマが入っていてもダメ
1.23e+3 0 指数表記もダメ
1.23e-3 0 指数表記もダメ
0x3C1 0 16進数もダメ

DecimalToIntegerは普通の小数(1.1など)を入力とするときは想定通り動作しました。ただし、カンマ区切り(1,234)、指数表記(1.23e+3)、16進数(0x3C1)はエラーになってしまいました。

TextToIntegerに関してはほぼ全滅でした。そこでDecimalToInteger(TextToDecimal)に変更したところDecimalToIntegerと似たような挙動となりました。ただし、4/3などを入力したときにDecimal expected!エラーではなく0を出力するという点が異なります。

想定外の挙動を示したものについてもう少し補足

  • 国によってはカンマを小数点として利用します。そのため、カンマ区切りの数字を扱えないのはまずいのでは?と思い検索したところ、同じように困っている人がいました。DateFormatはService Centerから選べるのにDecimalやCurrencyが選べないのは不便だよねという意見があり、これを改善しようとするアイディアがあったのでいいねしておきました
  • 指数表記に関しては、こちらには扱えるような会話がありますが、色々試したもののやはり扱えませんでした。どなたが方法をご存知の方がいれば教えて頂きたいです
  • 16進数についてはやはりデフォルトでは扱えないようでForgeのComponentを使うとよさそうです

まとめ

  • 普通の小数の表記(1.1など)をする分にはDecimalToIntegerは直感的に使える(四捨五入する点は注意)
  • カンマを区切り文字とする場合(1,234など)、指数表記(1.23e+3など)、16進数(0x3C1など)はDecimalToIntegerは使えないため、個別の対応が必要
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?