Jump to content

XP's calc.exe for binary, hex, decimal conversions


tain

Recommended Posts

I've never been a numbers guy but am trying to get proficient at using calc.exe to do number conversions. A "quick reference" sheet would be ideal but I can't find one and am getting skeptical that one exists.

Is there some source (tutorial, .chm, cheat sheet) that will help me perform operations such as:

-257 decimal to hex big endian

-257 decimal to hex little endian

-23 hex little endian to binary floating point little endian (lots of conversions there)

Convert the 32bit little endian hex value 12 3F 2B A7 into both signed and unsigned decimal

For example, a 16bit signed hex value (FF F6) (which happens to be negative) to a decimal:

Scientific mode

Input FFF6 in Hex mode with a size of Word.

Perform Two's Complement:

...Click Not to invert the binary values.

...Add 1.

...Click Equals.

Switch from Hex to Decimal mode.

Remember that the number displayed (10) is actually negative (-10) due to the negative signed bit from the original hex value.

Link to comment
Share on other sites


That software looks very interesting and I'll certainly check it out. But unfortunately I work in an environment that prohibits electronic devices (such as a TI calc or a thumb drive) as well as internet access. So there is no way to run this software where I really need it. Thus my need to squeeze all the power out of calc.exe that I can :}

Link to comment
Share on other sites

Thus my need to squeeze all the power out of calc.exe that I can :}

I see. :)

And you cannot have a worksheet, like Excel/OpenOffice.org/Spread32 too? :unsure:

I usually do all my "hex thingies" in one of them.

However, first two are easy:

-257 decimal to hex big endian

-257 decimal to hex little endian

On calc:

Hex [x]

Word [x]

Dec [x]

2

5

7

+/-

Hex [x]

Result=FEFF (which is "plain" or "Motorola" or "Little Endian") you just exchange the bytes and you get ->FFFE (which is "Big Endian" or "Intel")

Again:

Hex [x]

DWord [x]

Dec [x]

2

5

7

+/-

Hex [x]

Result=FFFFFEFF (which is "plain" or "Motorola" or "Little Endian") you just exchange the bytes and you get ->FFFEFFFF (which is "Big Endian" or "Intel")

For example, a 16bit signed hex value (FF F6) (which happens to be negative) to a decimal:

Scientific mode

Input FFF6 in Hex mode with a size of Word.

Perform Two's Complement:

...Click Not to invert the binary values.

...Add 1.

...Click Equals.

Switch from Hex to Decimal mode.

Remember that the number displayed (10) is actually negative (-10) due to the negative signed bit from the original hex value.

This seems easier to me :unsure::

Hex [x]

Word [x]

FFF6

+/-

Dec [x]

+/-

(you just need to remember to press twice the +/-, once when you input the negative Hex and once when the (positive) result is displayed)

For floating point, you should take notes/study these:

http://babbage.cs.qc.edu/IEEE-754/Decimal.html

http://babbage.cs.qc.edu/IEEE-754/32bit.html

http://babbage.cs.qc.edu/IEEE-754/64bit.html

jaclaz

Link to comment
Share on other sites

And you cannot have a worksheet, like Excel/OpenOffice.org/Spread32 too? :unsure:

Potentially. But 1) I need to be mobile 2) There are multiple, independent networks in the same physical environment so I couldn't always transfer a spreadsheet around.

You methods look good, but you got the Endianness reversed. Intel is Little Endian whereas Motorola is Big.

Here is a stupid question from a non-math guy: why did you change from word to dword? The math is the same except for the extra 1-bits (Fs). Are you trying to change the endianness in the calcuator or are you trying to manually display the extra bits at the end to make it easier to remember the full state?

This seems easier to me :unsure::

Hex [x]

Word [x]

FFF6

+/-

Dec [x]

+/-

That is certainly a faster/easier way to do it. But the behavior or +/- is not consistent in my calc. For example, if you go back to hex at the end of the steps you outlined and then hit +/- again you will get 'A' instead of '-FFF6'. Why does the behavior change?

I will study these and pose questions soon :)

Link to comment
Share on other sites

You methods look good, but you got the Endianness reversed. Intel is Little Endian whereas Motorola is Big.

You are right, my bad. :blushing:

Here is a stupid question from a non-math guy: why did you change from word to dword? The math is the same except for the extra 1-bits (Fs). Are you trying to change the endianness in the calcuator or are you trying to manually display the extra bits at the end to make it easier to remember the full state?

No, it was just an example, from another non-math guy. ;)

That is certainly a faster/easier way to do it. But the behavior or +/- is not consistent in my calc. For example, if you go back to hex at the end of the steps you outlined and then hit +/- again you will get 'A' instead of '-FFF6'. Why does the behavior change?

Well, yes :), but not exactly.

Hex [x]

FFF6

+/- -> -FFF6

Number is somehow "parsed" and put in the stack only now. (but the value of the stack is actually "A", which then converts nicely to "10")

Dec [x] -> 10

+/- -> -10

Hex [x] ->FFF6

Number is already into the stack.

+/- -> A

Dec [x] -> 10

+/- -> -10

Hex [x] ->FFF6

etc. etc.

It seems like calc.exe "autoconverts" negative hex values to positive ones.

Try the following:

Hex [x]

0

-

A

= -> FFF6

+/- -> A

Dec [x] -> 10

+/- -> -10

and loop as per above.

In other words, when you know that you are dealing with a negative hex number you need to press twice +/-, once in Hex[x] and once in Dec[x], when converting to Dec.

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

There are two kinds of people, those who really know their medications and dosages and those who do not.

Scary :o

I take this little pink one at night, 1/2 of this big pale yellow one in the morning, and this white oval one when I feel it coming on! :o

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...