I’m using: SWI-Prolog version 8.2.4 (pre-built Windows 64-bit version) (but also tested it with newest 8.4.2)
I use format/2 to print out a float number using ~ne format specifier. There I see some strange behavior:
format('~1e', [1e-3]).
This results in 1.0e-03
, i.e., the exponent is zero-padded to two digits, which conforms to the C standard for printf function. The same holds for all n > 0.
However, when I call
format('~0e', [1e-3]).
I get 1e-003
, i.e. the exponent has three digits now.
I know the print behavior depends on the used C library, but I find it someway inconsistent in the Windows version of Prolog.
I quickly checked the same with printf and some C compilers I have on my system: For gcc (7.4.0) it is always zero-padded to two digits and with Visual Studio (2010) it is always zero-padded to three digits.
So the question is: Is the reason for this inconsistent behavior the C library used in the pre-built Windows version or is there some special handling in the Prolog implementation?