Opened 9 years ago

Last modified 8 years ago

#631 new defect

trunc(768.3156) == 770?!

Reported by: Jiri Svoboda Owned by:
Priority: major Milestone:
Component: helenos/unspecified Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also:


Adding the code fragment

TPRINTF("trunc(768.3156)=%lf\n", trunc(768.3156));

to tester yields the output


However the float2 test succeeds, because after multiplication by precision and conversion to integer the result is as expected.

Change History (2)

comment:1 by Martin Decky, 8 years ago

On what platform do you observe this? Could it be an issue in the printf?

If I port both the generic code (uspace/lib/math/generic/trunc.c) and the ia32-specific FPU code to Linux, I don't observe this behavior.

comment:2 by Martin Decky, 8 years ago

OK, it's very probably a bug in printf and not in the arithmetic functions. The following code

printf("768.3156=%lf\n", 768.3156);
printf("768.3150=%lf\n", 768.3150);
printf("768.3100=%lf\n", 768.3100);
printf("768.3000=%lf\n", 768.3000);
printf("768.0000=%lf\n", 768.0000);

produces the following output

Note: See TracTickets for help on using tickets.