Upon writing a program to convert *.csv-files, I stumbled upon some issues regarding "Print", "Print Using" and "Format".
I.
The print statement doesn't print single-variables correctly, if the value of the variable is > 1000000 it does not display the decimal places:
Dim As Single sngValue
sngValue=1000000.2 (or any number > 1000000)
Print sngValue --> Output: 1000000 instead of 1000000.2
II.
If a variable is >1 million it doesn't interpret the using-clause correctly, and performs incorrect rounding:
Dim As Single sngValue
sngValue=1664465.2
Print Using "####,###.##"; sngValue
Output --> "1,664,465.25"
instead of "1664,465.20"
III.
format on the other hand accounts for regional settings, but
doesn't interpret the formatstring correctly
performs incorrect rounding:
sngValue=100000.2
Print Format(sngValue,"####,###.##")
Output --> "100.000,20"
expected--> " 100.000,20"
sngValue=1000000.2
Print Format(sngValue,"####,###.##")
Output --> "1.000.000,19"
expected--> "1000.000,20"
but
dblValue=1000000.2
Print Format(dblValue,"####,##0.00")
Output --> "1.000.000,2"
expected--> "1000.000,20"
Logged In: YES
user_id=723706
Originator: NO
The problems you are having are because you're pushing right up against the accuracy limits of the Single number format. It's only accurate up to about 7 decimal digits. Try this program:
dim i as integer, s as single, d as double
for i = 0 to 11
d = d * 10 + i mod 10
s = csng(d)
print using "########### "; s, d
next i
I can't reproduce your last Format problem with dblValue. (I'm assuming that's supposed to be a Double.) What operating system and FreeBASIC version are you using (try running "fbc -version")? It might also help to know your regional settings.