converting float to int issue
Alex
delete.this.part.alex.news at attbi.com
Mon May 5 15:49:13 EDT 2003
Irmen de Jong wrote:
> [OFFTOPIC]
>
> Alex wrote:
>> Found the problem and resolution:
>> http://forums.gentoo.org/viewtopic.php?t=27211
>
> Sorry for this second follow up but I just noticed that
> the little C test code they give on that forum is NOT CORRECT.
>
> It does:
>
> printf("fractional part = %f\ninteger part = %f\n", modf(x, &y), y);
>
>
> And as we all know, the order in which the modf and the y argument are
> evaluated is uncertain. That's why they got 0.0000 for the integer part
> in the result (and sometimes 1.000) . They should have done this:
>
> double result = modf(x,&y);
> printf("fractional part = %f\ninteger part = %f\n", result, y);
>
> At first, the code produced the "wrong" results on my system, too.
> After the fix, it produces the correct results.
>
> Alex, are you on that forum? You might want to point this out over
> there...
>
> --Irmen de Jong
No I've never had a reason to join. I guess now would be a good time.
Alex
More information about the Python-list
mailing list