Difference between revisions of "Category talk:LSL Integer"
Jump to navigation
Jump to search
m (Polish: Add one missing instance of "is", insert consistent whitespace) |
|||
Line 3: | Line 3: | ||
:Aye correct as saved. | :Aye correct as saved. | ||
:This truth makes more visual sense in hex. A 32-bit two's complement integer 0x0, or +0x1 thru +0x7FFFffff, or -1 thru -0x7FFFffff, or -0x80000000. In decimal, that is 0, or 1 thru 2147483647, or -1 thru -2147483647, or -2147483648. The assymetry comes from the zero: both positive integers and zero have the uppermost most bit of the 32 bits zeroed, so the list of positive values loses one element to make room for zero. | :This truth makes more visual sense in hex. A 32-bit two's complement integer is 0x0, or +0x1 thru +0x7FFFffff, or -1 thru -0x7FFFffff, or -0x80000000. In decimal, that is 0, or 1 thru 2147483647, or -1 thru -2147483647, or -2147483648. The assymetry comes from the zero: both positive integers and zero have the uppermost most bit of the 32 bits zeroed, so the list of positive values loses one element to make room for zero. | ||
:A correspondingly counterintuitive result here is that negating -2147483648 has no effect (-2147483648 == ( 0 - -2147483648 ) == ( 2147483647 + 1 ) ). Ugly as all this is, it's less ugly than the known alternatives, such as the one's complement encoding that can have two zeroes: a positive zero and a negative zero. All that I'm saying here is the convention I remember learning years ago, I imagine LSL behaves this way at these limits, but I haven't tried to see yet ... -- [[User:Ppaatt Lynagh|Ppaatt Lynagh]] 18:10, 27 June 2009 (UTC) | :A correspondingly counterintuitive result here is that negating -2147483648 has no effect (-2147483648 == ( 0 - -2147483648 ) == ( 2147483647 + 1 ) ). Ugly as all this is, it's less ugly than the known alternatives, such as the one's complement encoding that can have two zeroes: a positive zero and a negative zero. All that I'm saying here is the convention I remember learning years ago, I imagine LSL behaves this way at these limits, but I haven't tried to see yet ... -- [[User:Ppaatt Lynagh|Ppaatt Lynagh]] 18:10, 27 June 2009 (UTC) | ||
Thanx Ppaatt. I thought it might be a zero issue but didn't get as far as thinking that (of course) there would have to be (as you say) two zeros for the reach (both pos and neg) to be equal. "Positive Zero". Sounds like a good title for a science fiction novel. Cheers Ppaatt. -- '''[[User:EddyFragment Robonaught|Eddy]]''' <sup><small>([[User talk:EddyFragment_Robonaught|talk]]|[[Special:Contributions/EddyFragment_Robonaught|contribs]])</small></sup> 18:16, 27 June 2009 (UTC) | |||
::Thanx Ppaatt. I thought it might be a zero issue but didn't get as far as thinking that (of course) there would have to be (as you say) two zeros for the reach (both pos and neg) to be equal. "Positive Zero". Sounds like a good title for a science fiction novel. Cheers Ppaatt. -- '''[[User:EddyFragment Robonaught|Eddy]]''' <sup><small>([[User talk:EddyFragment_Robonaught|talk]]|[[Special:Contributions/EddyFragment_Robonaught|contribs]])</small></sup> 18:16, 27 June 2009 (UTC) |
Revision as of 06:24, 28 June 2009
Are these numbers correct? "values between −2,147,483,648 and +2,147,483,647" . And if they are why the difference between the figures? -- Eddy (talk|contribs) 17:30, 27 June 2009 (UTC)
- Aye correct as saved.
- This truth makes more visual sense in hex. A 32-bit two's complement integer is 0x0, or +0x1 thru +0x7FFFffff, or -1 thru -0x7FFFffff, or -0x80000000. In decimal, that is 0, or 1 thru 2147483647, or -1 thru -2147483647, or -2147483648. The assymetry comes from the zero: both positive integers and zero have the uppermost most bit of the 32 bits zeroed, so the list of positive values loses one element to make room for zero.
- A correspondingly counterintuitive result here is that negating -2147483648 has no effect (-2147483648 == ( 0 - -2147483648 ) == ( 2147483647 + 1 ) ). Ugly as all this is, it's less ugly than the known alternatives, such as the one's complement encoding that can have two zeroes: a positive zero and a negative zero. All that I'm saying here is the convention I remember learning years ago, I imagine LSL behaves this way at these limits, but I haven't tried to see yet ... -- Ppaatt Lynagh 18:10, 27 June 2009 (UTC)
- Thanx Ppaatt. I thought it might be a zero issue but didn't get as far as thinking that (of course) there would have to be (as you say) two zeros for the reach (both pos and neg) to be equal. "Positive Zero". Sounds like a good title for a science fiction novel. Cheers Ppaatt. -- Eddy (talk|contribs) 18:16, 27 June 2009 (UTC)