010 < 9 is True or False?

010 < 9 は真か偽か?

The answer depends on the context.
In some cases, a string which consists of digits beginning with zero will be interpreted as an octal number (010 is equal to 8 in decimal number). But there also be cases where a digit string will be always interpreted as a decimal number, i.e. leading zero(s) will be ignored.

2014-12-09: I heard that the numeric interpretation will be changed in FME 2015. That is, new transformer instances in FME 2015 always attempts to interpret a numeric value as a decimal number even if its representation begins with zero.
Note that this article is true for FME 2014 and earlier, but will not be true for FME 2015+.
2014-12-09: FME 2015では数値の解釈に変更があると聞きました。つまり、FME 2015の新しいトランスフォーマーインスタンスは、ゼロから始まっていたとしても常に十進数として解釈しようとします。
この記事はFME 2014以前には当てはまりますが、FME 2015以降には当てはまらないことに注意してください。

Arithmetic Expressions 数式
In an arithmetic expression that is evaluated by @Evaluate function, "010" will be interpreted as an octal number; the value is treated as 8 in decimal number. But if the representation is "010.0" - having decimal fraction, the value is treated as 10.0 in decimal number even though it begins with zero(s).

Check resultant values generated by the AttributeCreator with the following settings.
- n1 will store "010" (the representation was assigned as-is),
- n2 will store "8" (evaluated as an octal number),
- n3 will store "10.0" (evaluated as a decimal number), after the processing.
次の設定で AttributeCreator が生成する結果を確認してください。処理後、
- n1 は"010"(文字列表現がそのまま割り当てられた)、
- n2 は"8"(八進数として評価された)、
- n3 は"10.0"(十進数として評価された)を格納することになります。

Comparison in Test Clauses テスト句における比較
In a test clause (Automatic or Numeric Mode), the transformer attempts to interpret a string as a decimal number; ignores leading zero(s). For example, if an attribute named "src" contains "010", the Tester with this setting routes the feature to the Failed port (10 < 9 is false).
テスト句(AutomaticまたはNumericモード)では、トランスフォーマーは文字列を十進数として解釈しようとし、先頭部のゼロを無視します。例えば、"src"という名前の属性が"010"を格納している場合、次の設定をした Tester は、フィーチャーを Failed ポートに送ります (10 < 9 は偽)。

However, if the Left Value was an arithmetic expression which evaluate the attribute value, the feature goes to the Passed port, since "010" will be evaluated as an octal number (8 < 9 is true).
しかし、Left Value(左辺値)が属性値を評価する数式である場合は、"010"は八進数として評価されるため、フィーチャーは Passed ポートから出力されます (8 < 9 は真)。

Sorter transformer  Sorter トランスフォーマー
The Sorter (Numeric mode) seems to always consider a numeric representation as a decimal number. This is a sorted result by numeric ascending.

I sometimes come across a case where code numbers beginning with 0 should be treated as numeric values. In such a case, be aware that there are differences on the interpretation depending on the context.

No comments:

Post a Comment