The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

WP34S x=? in integer mode
Message #1 Posted by Harald on 13 Mar 2012, 9:48 a.m.

I have written a little program to "benchmark" a few of my calculators. It simply adds all the integers from the start value down to 1. I am using x=0? to determin when to stop. Out of interest I wanted to see what happens if I put the calculator into integer mode and discovered something that I do not understand. x=0? returns "true" for x being -75. Can someone explain why that is?

According to the manual I should use x=+0? or x=-0?, but haven't tried that yet (forgot the calculator at home)

Cheers, Harald

Edited: 13 Mar 2012, 9:48 a.m.

      
Re: WP34S x=? in integer mode
Message #2 Posted by Dominic Richens on 13 Mar 2012, 11:35 a.m.,
in response to message #1 by Harald

notwithstanding what the manual says about x=-0 and x=+0, x=0? should still work as expected in integer mode.

Not only does -75 x=0? return true, 0 x=0? returns false!

            
Re: WP34S x=? in integer mode
Message #3 Posted by Walter B on 13 Mar 2012, 2:49 p.m.,
in response to message #2 by Dominic Richens

Good find :-) Strange things happening there: -16 x=0? returns (correctly) false, so what's happening in between? We'll look into that. Thanks for reporting!

                  
Re: WP34S x=? in integer mode
Message #4 Posted by Marcus von Cube, Germany on 13 Mar 2012, 2:56 p.m.,
in response to message #3 by Walter B

I have an idea where to look but I need time to investigate it.

      
Re: WP34S x=? in integer mode
Message #5 Posted by Paul Dale on 13 Mar 2012, 5:13 p.m.,
in response to message #1 by Harald

Fix committed but not built. This was a result of the rearrangement of the internal constants table recently. There was a second bug where the integer test against 1 was really against -1 :-(

You only need to use x=+0? and x=-0? in special occasions and if you don't know or understand when, you don't need to use them :-) Just use x=0? instead.

- Pauli

            
Re: WP34S x=? in integer mode
Message #6 Posted by Harald on 13 Mar 2012, 6:27 p.m.,
in response to message #5 by Paul Dale

Quote:
You only need to use x=+0? and x=-0? in special occasions and if you don't know or understand when, you don't need to use them :-) Just use x=0? instead.

- Pauli


So basically you are saying they are only interesting if I am using ones' complement because then I have both +0 and -0? But x=0? should be true for both +0 and -0?
                  
Re: WP34S x=? in integer mode
Message #7 Posted by Paul Dale on 13 Mar 2012, 6:46 p.m.,
in response to message #6 by Harald

Quote:
So basically you are saying they are only interesting if I am using ones' complement because then I have both +0 and -0? But x=0? should be true for both +0 and -0?

That is a third of the ways negative zero can appear.

The sign & mantissa integer mode also has positive and negative zero. This isn't really any different to the 1s complement mode however.

Real numbers have positive and negative zeros, which is invaluable for numerical programming. You'll have to set flag D to see the difference.

And yes, x=0? is true for both positive and negative zero.

- Pauli

                        
Re: WP34S x=? in integer mode
Message #8 Posted by Harald on 13 Mar 2012, 6:57 p.m.,
in response to message #7 by Paul Dale

Quote:
Real numbers have positive and negative zeros, which is invaluable for numerical programming. You'll have to set flag D to see the difference.

I never thought about that, but I suppose it helps to know which side you are approaching a limit from.

Quote:
And yes, x=0? is true for both positive and negative zero.

- Pauli


Ok, thanks for the info!

Harald

                              
Re: WP34S x=? in integer mode
Message #9 Posted by Paul Dale on 13 Mar 2012, 7:00 p.m.,
in response to message #8 by Harald

Quote:
...I suppose it helps to know which side you are approaching a limit from.

Exactly. Very useful for complex branch cuts e.g.

- Pauli


[ Return to Index | Top of Index ]

Go back to the main exhibit hall