OT: hex to decimal conversion

Part 2 of the computer project. (Installing CNC control on new puter) I need to convert these hex values to decimal

DC00 - DC1F E000 - E01F

May need more, if there's a free converter. I thought windoze used to have one, couldn't find it.

Karl

Reply to
Karl Townsend
Loading thread data ...

In the windows calculator View- Scientific, just enter them in hex and click dec

Reply to
Forger

formatting link

Reply to
Lane

Standard calculator - in the Scientific mode - does hex to ...easy. Windows.

56320 - 56351 57344 - 57375

If I didn't do a typo. Martin

Reply to
Martin H. Eastburn

Bring up the Windows calculator (should be in the Accessories folder). Now click "view" and select "scientific" from the drop down menu. Now click "hex" and enter your number. Click "dec" and the calculator will display the decimal equivalent. Example, enter DC00, click "dec", and see 56,320.

Gary

Reply to
Gary Coffman

In an emergency you can do it manually:

DC1F = 15 + 1*16 + 12*16^2 + 13*16^3

8-)

Leon

Reply to
Leon Heller

Give a man a fish... DC00 = 56320 -- DC1F = 56351

Teach him to fish... In hex, the digits are 0-9 = 0-9, just like decimal, along with some "extras" - A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.

So... (Notice the pattern of "16^#" terms...) DC00 = (D * 16^3) + (C * 16^2) + (0 * 16^1) + (0 * 16^0) = (13 * 16^3) + (12 * 16^2) + (0 * 16^1) + (0 * 16^0) = (13 * (16*16*16)) + (12 * (16*16)) + (0 * (16)) + (0 * (1)) = (13 * (4096)) + (12 * (256)) + (0 * (16)) + (0 * (1)) = (53248) + (3072) + (0) + (0) = DC00 = 56320

The pattern of "16^#" terms continues to the left, like so...

16^0 = 1 16^1 = 16 16^2 = 256 16^3 = 4096 16^4 = 65536 16^5 = 1048576 16^6 = 16777216 16^7 = 256435426 16^8 = (and so on, to infinity)

So try 0x20B31AE4....

0x20B31AE4 = ??

(2 * 16^7) = 536870912 (0 * 16^6) = 000000000 (B * 16^5) = 12582912 (3 * 16^4) = 196608 (1 * 16^3) = 4096 (A * 16^2) = 2560 (E * 16^1) = 224 (4 * 16^0) = 4 =========

0x20B31AE4 = 549657316

You fishin' yet? :)

Reply to
Don Bruder

Still does. Click the view button and select the scientific option.

Paul

formatting link

Reply to
Paul

I hate it when a thread gets split up and I reply to the newer split and then discover the remaining posts already have the info I was trying to help with.

Paul

Reply to
Paul

Windoze does. use the calculator (calc.exe) and set the view to scientific

Mark Rand RTFM

Reply to
Mark Rand

Are you ready for the smartass answer?

;----------------------------------------------------------------------------- ; ; Print_decimal ; ; Convert AX into a 1-5 char decimal number, strip leading ; zeros and print it. ; print_decimal: push ax push bx push cx push si push di

mov si,offset bcd_table mov di,offset result mov cx,16 convert_loop: shr ax,1 jc do_long_add add si,5 loop convert_loop jmp convert_done do_long_add: call long_add mov di,offset result loop convert_loop

convert_done: mov di,offset result mov cx,5 mov ah,0 ; leading zero flag print_long: mov al,[di+4] add ah,al jz leading_zero or al,30h call print_char leading_zero: dec di loop print_long cmp ah,0 jne print_long_done mov al,'0' call print_char print_long_done:

mov di,offset result mov cx,5 clear_long: mov byte ptr [di],0 inc di loop clear_long pop di pop si pop cx pop bx pop ax ret long_add: push cx mov cx,5 long_add_loop: mov bl,[si] add bl,[di] cmp bl,9 jbe no_carry sub bl,10 inc byte ptr [di+1] no_carry: mov [di],bl inc si inc di loop long_add_loop pop cx ret result: db 0,0,0,0,0

bcd_table: db 1,0,0,0,0 ; each entry is power of 2 multiple db 2,0,0,0,0 ; of the previous, in backwards db 4,0,0,0,0 ; order. This is because we have db 8,0,0,0,0 ; to add from lsd to msd. db 6,1,0,0,0 db 2,3,0,0,0 db 4,6,0,0,0 db 8,2,1,0,0 db 6,5,2,0,0 db 2,1,5,0,0 db 4,2,0,1,0 db 8,4,0,2,0 db 6,9,0,4,0 db 2,9,1,8,0 db 4,8,3,6,1 db 8,6,7,2,3

decimal_table: ; Ascii codes of 2 char decimal db '00010203040506070809' ; numbers from 00 to 99 db '10111213141516171819' db '20212223242526272829' db '30313233343536373839' db '40414243444546474849' db '50515253545556575859' db '60616263646566676869' db '70717273747576777879' db '80818283848586878889' db '90919293949596979899' 

Reply to
Jim Stewart

Reminds me of that other saying. Give a man a match and he'll be warm for the night. Set a man on fire and he'll be warm for the rest of his life.

Reply to
Dave Baker

DC00 - DC1F = 56320 - 56351 E000 - E01F = 57344 - 57375

Ron

Reply to
Ron Eastes

the smartass answer would be 3 lines of C Pat

void main(void) { int i; scanf("input:%x",&i); printf("\n %x is %d",i,i); }

Pat

;---------------------------------------------------------------------------

--

 

Reply to
Pat Ford

Nah, the first smartass had to code it in assembly language in the C compiler so that when you write your 3 lines of code, his assembly/machine language gets called (:

Reply to
Jim Stewart

  1. > void main(void)
  2. > {
  3. > int i;
  4. > scanf("input:%x",&i);
  5. > printf("\n %x is %d",i,i);
  6. > }

The smartest assed answer would be one line of QuickBasic:

INPUT "Enter hex number:", hx$: PRINT VAL("&H" + hx$)

:^)

Which reminds me, I recently completed (more or less) a useless but complicated program that lets you place points in 3D space (build voxel models and such). It has three edit windows (XZ, XY and YZ), a fly-through-space mode and can load and save files at will. Anyone want to see?

Tim

-- "I've got more trophies than Wayne Gretsky and the Pope combined!" - Homer Simpson Website @

formatting link

Reply to
Tim Williams

In the search box on Google (no quotes):

"0xDC00 in decimal"

Will result in:

56320

Never under estimate the power of the Google calculator...

formatting link
Regards,

Robin

Reply to
Robin S.

Almost all C compilers are written in C.

Adam Smith, Midland > > the smartass answer would be 3 lines of C

;---------------------------------------------------------------------------



Reply to
Private

MAN I COULD REALLY USE YOUR SMARTASS HELP HERE!!

Could either one of you folks write and compile something to read the next

16 bits, or two bytes at address DC00 and the same for address E000? print it to a file or screen or whatever is easiest.

The vendor and I are going round and round on getting data at this address into the control program. It would be very helpful to know if its there and readable. This is just pins on an I/O card at 0 or 5 volts.

Karl

Reply to
Karl Townsend

Are you reading I/O ports or memory locations?

Could you explain exactly what you are doing now to get your data?

From what I think I understand, the program would be about a 10 minute job.

jim

Reply to
Jim Stewart

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.