Opened 20 months ago
Last modified 20 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: |
Description
I recently added CHICKEN 5.3.0 to my package manager for OS X Tiger/PowerPC and Leopard/PowerPC: https://github.com/cellularmitosis/leopard.sh/commit/192014b920692434337783199742ceb217694f27
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 CHICKEN (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) -0.0 #;2>
Thanks for all of your work on CHICKEN!
Change History (5)
comment:1 Changed 20 months ago by
comment:2 Changed 20 months ago by
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 20 months ago by
Surprisingly, modf(1.0, &x)
returns 0.000000.
comment:4 Changed 20 months ago by
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
.
Interestingly, 0.0 and -0.0 compare equal, so I'm not sure if this can actually cause a problem.