SciCalc can't do 32 bit hex
Tristan M. (2946) 1039 posts |
I think this is a bug. Surely people use it when working things out when programming in RISC OS, right? |
James Wheeler (3283) 344 posts |
What result did you get? It’s suppose to be 0×7FFF FFFF, isn’t it? |
Jeffrey Lee (213) 6048 posts |
Yeah, I’d say this is a bug. 0xbfffffff will get converted to a negative 32bit int, and then to a double-precision float. Subtracting 0×40000000 then pushes it outside the range of a 32bit signed int, so when displaying the result the conversion from double → int (ready for int → hex) fails. Admittedly SciCalc’s Help file does say it supports signed 32bit hex (whereas you want unsigned), but if this was really true then it should use hex numbers in the range -0×80000000 to 0×7fffffff instead of 0×80000000 to 0×7fffffff.
BASIC in a taskwindow is my go-to. SciCalc is just pathetic (what’s the point of using double-precision arithmetic if your input & output is limited to 9 digits?). I’m not a big fan of the builtin Windows & OS X equivalents either (e.g. “programmer” modes which are restricted to integers) |
Tristan M. (2946) 1039 posts |
James, Yes 0×7FFF FFFF was the answer I should have seen. However the answer the calculator gave was literally “number too small”. I worked it out in my head after that instead of being lazy, and verified with a Casio calculator. Interestingly gcalc in Linux does similar but spits out “inf” instead. Jeffrey, that behaviour is just bizarre. I’m surprised that SciCalc doesn’t handle it or at least catch it with some bounds checking I was bashing out a header with the base addresses and sizes for the H3 Cortex A7 memory map. The rest were straightforward, but I wanted to check I was right with RAM address space understandably. Can’t say I’ve ever broken a calculator on a computer before. |
Ronald May (387) 407 posts |
I’m not sure what Jeffrey means by using BASIC, but a standard large number doesn’t work
I cross-compiled kalc with the linux line editor but I think the style of entry would work well in NettleSSH ANSI mode/with editor mode enabled. kalc uses RPN but that is minor compared to learning the other options, The useage is explained in the pdf quite clearly if you are patient. It has logic functions and shifts etc, didn’t notice anything for 2’s compliment stuff. |
Jeffrey Lee (213) 6048 posts |
I’m not sure what Jeffrey means by using BASIC, but a standard large number doesn’t work Well, it’s not like that example works in SciCalc either :-) Clearly if you’re using BASIC then you’ll be restricted to the limits of BASIC. But the key thing is that BASIC/BASIC64 has fewer limits than SciCalc.
BASIC has its flaws, but it’s miles better than calculator apps that are designed to mimic the form and function of physical calculators. |
Rick Murray (539) 13840 posts |
+1 I think the only time I ever use SciCalc is when I want to see something expressed as a bitfield. Otherwise… So, yeah, BASIC FTW. :) |
Ronald May (387) 407 posts |
didn’t notice anything for 2’s compliment stuff. Kalc uses the neg operator for 2’s compliment of a number I think kalc follows the HP calculator stack operations style but has a bit more desktop enhancement.Probably not as nice as BASIC for hands on and flexibility (as explained by Rick and Jeffrey) but it can do large numbers properly. Hard disc sizes get well above 32bits is one example, and could check ones code results. |