Two questions about "%a"

Magnus Lie Hetland magnus at hetland.org
Wed Mar 2 04:35:11 PST 2011


First question: I just noticed that writefln("%a", 1.2) writes 
0x1.3333333333333p+0, while writeln(format("%a", 1.2)) (that is, with 
std.string.format) writes 0x9.9999999999998p-3 ... wouldn't it be nice 
to be consistent here? (The former is what printf in gcc gives.) Or am 
I missing a difference in functionality?

Second question: Just to make sure, this *is* an exact representation 
of the underlying floating-point number? (I.e., if that'w what I'm 
after, using %a *is* the way to go?)

-- 
Magnus Lie Hetland
http://hetland.org



More information about the Digitalmars-d-learn mailing list