There’s a special place somewhere for whoever thought of this. The intrinsic functions AsInteger and AsNumber work in very different ways and I believe they are so badly named that this “feature” is a bug.
Anyway, that is how it is in RDMLX.
Which of these functions can be used to convert the content of a string to a numeric value? Like the string “53”?
Yes, it is a naughty example, because if you run both of these on Windows you get the same result, 53.
#STR := "53"
#NUM := #STR.AsNumber /* returns 53 */
#INT := #STR.AsInteger /* returns 53 */
But that is a trick. On IBM i I would have needed to use “242” to get the same value from both functions because
AsInteger returns the character code of the first character in the string
True, that will be an integer, but the name of the function is terrible.
The reason the code above gives the same result is that the character code for “5” in ASCII (Windows) is 53, while the character code for “2” in EBCDIC (IBM i) is 242.
It does not matter how long the string is, AsInteger will only look at the first character.
But really, it should have been called something with CharCode.
Having said that:
As long as I don’t care about character codes, it is AsNumber I need to use.