KWK 0 Posted September 11, 2020 Generally in Pascal, writing a real, specifying field length and number of decimals, rounds to that number of decimals. Thus x:=1.27; writeln(x:3:1) produces "1.3" However, in DelphiXE2 x:=0.9; writeln(x:3:0) produces " 0" while x:=1.9; writeln(x:3:0) produces " 2". (This also happens if you just do writeln(0.9:3:0) and writeln(1.9:3:0) For some reason, reals with an absolute value less than 1 are not rounded, but reals with an absolute value >1 are rounded. My example has just one decimal, but I discovered this while trying to print probabilities where writing a calculated value x:=0.000647; writeln(x:8:3) produced 0.000 rather than 0.001 which is correct. This appears to me to be a bug,. Is this true in more recent versions of RAD Studio? Thank you. Share this post Link to post
eivindbakkestuen 47 Posted September 12, 2020 (edited) writeln(x:3:0) produces " 1" in 10.4.1 afaiks (when x = 0.9) Edited September 12, 2020 by eivindbakkestuen missing value Share this post Link to post