User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 397,792 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,445 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:

FILE + conversion from dec to hex = I need help

Join Date: May 2006
Posts: 2,700
Reputation: WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold 
Rep Power: 14
Solved Threads: 219
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Maven

Re: FILE + conversion from dec to hex = I need help

  #3  
Nov 12th, 2006
This will load the hex values from smallest to largest:
make a character array (hexval) about 10 characters long
set whole array to spaces
set hexval[9] to '\0'
set hexptr to 8 -- this will point into hexval to load the hex chars.
Read a line into an integer (intval) -- that's base 10.
Loop until that integer is 0:
    set hexval[hexptr] = remainder of intval/16 
    add 48 ('0') to hexval[hexptr]  -- this converts the integer value to a digit character
    if hexval[hexptr] > 57 ('9') add 7 -- value is now 'A' - 'F'
    decrement hexptr  -- to load the next hex digit
    divide 16 from intval -- to remove the hex val we just loaded
    End of loop
Age is unimportant -- except in cheese
Reply With Quote  
All times are GMT -4. The time now is 5:37 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC