I am using format/2;3 to output numeric data to be fed into a foreign system, which is a bit strict on the characters used as a decimal point and thousands separator.
e.g. the number -9993.81 shall be formatted -9,993.81
With the following code, prolog will produce the expected value:
?- format('~2:f', -9993.81). -9,993.81 true.
However the manual at Predicate format/2 says:
“f: Floating point in non-exponential notation. The numeric argument defines the number of digits right of the decimal point. If the colon modifier ( : ) is used, the float is formatted using conventions from the current locale, which may define the decimal point as well as grouping of digits left of the decimal point.”
This essentially makes the output dependant on the locale the user happens to have defined in his environment.
Luckily for me this fits well, but changing the settings in my shell may render my program unusable.
Is there a way to avoid this (e.g. a supplemental flag to ~f, or a prolog flag)?