www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - %x and floats

reply Trass3r <un known.com> writes:
Why doesn't this work:

import std.stdio;
void main()
{
	float a,b=0;
	writefln("%x %x", a, b);
}

std.format.FormatError: std.format floating
Feb 24 2011
parent "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
On Thu, 24 Feb 2011 13:27:39 -0500, Trass3r wrote:

 Why doesn't this work:
 
 import std.stdio;
 void main()
 {
 	float a,b=0;
 	writefln("%x %x", a, b);
 }
 
 std.format.FormatError: std.format floating
That is because %x is for formatting integers. If you want a hex representation of a floating-point number, use %a. http://www.digitalmars.com/d/2.0/phobos/std_format.html -Lars
Feb 25 2011