Opened 18 months ago

Last modified 18 months ago

#1814 new defect

OS X / PowerPC failing test: remainder return -0.0

Reported by: cellularmitosis Owned by:
Priority: minor Milestone: someday
Component: unknown Version: 5.3.0
Keywords: remainder Cc:
Estimated difficulty:


I recently added CHICKEN 5.3.0 to my package manager for OS X Tiger/PowerPC and Leopard/PowerPC:

When I ran the tests, there was only one failure:

(FAIL) remainder: flo/flo: expected 0.0 but got -0.0

I also verified it by hand:

$ csi
(c) 2008-2021, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.3.0 (rev e31bbee5)
macosx-unix-gnu-ppc [ 32bit dload ]

Type ,? for help.
#;1> (remainder 1.0 1.0)

Thanks for all of your work on CHICKEN!

Change History (5)

comment:1 Changed 18 months ago by cellularmitosis

Interestingly, 0.0 and -0.0 compare equal, so I'm not sure if this can actually cause a problem.

#;1> (= 0.0 -0.0)

comment:2 Changed 18 months ago by sjamaan

It shouldn't cause a problem in practice, I think. For dividing flonums we rely on the libc modf() function which is according to the standard is supposed to return the same sign as its input.

Perhaps you can test in a simple C function what modf(1.0, &x) returns and what it stores in x?

comment:3 Changed 18 months ago by cellularmitosis

Surprisingly, modf(1.0, &x) puts 0.000000 in x.

Last edited 18 months ago by cellularmitosis (previous) (diff)

comment:4 Changed 18 months ago by sjamaan

Since I don't have access to a PPC machine anymore, I'm afraid you're on your own for debugging this. Perhaps you can add some printfs to C_s_a_i_remainder in runtime.c. It's the most-indented code for flonums - check what the values of dx, dy and tmp are, and what the result is of the calculation it does in the call to C_flonum, i.e. dx - tmp * dy.

comment:5 Changed 18 months ago by cellularmitosis

thanks for the pointers!

Note: See TracTickets for help on using tickets.