AX / D365FO – The str2num function and decimal numbers

There seems to be an issue with the str2num function when what you want is a real value. This matters because it can be used to convert from a string to an int or a real.

In order to successfully convert from a string representation of a decimal value to an actual real type on X++, you can’t have any formats on your string. That means that the string has to be representing a double exactly as the real variable does: no thousand separator, and the dot (‘.’) character for the decimal separator.
It does not consider AX’s region when performing the conversion. Follow this post to solve the issue : https://devexpp.blogspot.com/2013/08/the-str2num-and-decimal-numbers.html

Leave a comment