floating-WTF

sclytrack sclytrack at fake.com
Tue Jan 24 07:47:07 PST 2012


On 01/24/2012 04:41 PM, sclytrack wrote:
> On 01/24/2012 01:51 PM, Dejan Lekic wrote:
>> No, it is not a bug.
>>
>> Here is a hint:
>>
>> import std.stdio;
>>
>> int main() {
>> float f;
>> writeln(f);
>> return 0;
>> }
>>
>> /+--- output ----------+
>> nan
>> +--- end of output ---+/
>>
>
> I don't understand.

I see now I forgot the input values. Sorry my IQ is 87.


void calculate2(float a, float b)
{
     float s1 = 1.0 - a;
     float s2 = a * b;
     writeln(s2);
     writeln(a * b);
}

-------INPUT values


int main()
{
	calculate2(0.75f,2.0f);
	return 0;
}

----------------
Output:
t*b= 0
t*b= 1.5
----------------




More information about the Digitalmars-d-learn mailing list