![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bourne and decimals?? | kdyzsa | Shell Programming and Scripting | 1 | 05-06-2008 10:54 PM |
| handle decimals | subin_bala | Shell Programming and Scripting | 1 | 04-21-2008 08:03 AM |
| Multiplying Floats/Decimals | rleebife | Shell Programming and Scripting | 10 | 08-02-2007 05:22 AM |
| comparing two numbers with the decimals | chittari | Shell Programming and Scripting | 4 | 06-28-2006 10:57 AM |
| getting the average of a list of decimals. | djsal | Shell Programming and Scripting | 2 | 04-24-2004 05:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Req on how to convert hex numbers to decimals
Hi,
If i have an input as c1:41 c2:0x0000.00046b3e I want to make output display as c1:41 c2:224062 . Basically convert first part 0x0000 (as hex) to decimal which is 0 and convert second part 0x00046b3e (as hex) to decimal which is 289598 and as such add both parts namely 0+289598=289598 . Is there a way to do this via awk or shell script? Thanks Hare. |
|
||||
|
Code:
#!/bin/ksh
# this does the math
echo "c1:41 c2:0x0000.00046b3e" | awk -F[:\.] '{ print $3, $4}' | read one two
result=$( printf "%d + %d" $one 0x"$two")
echo $result
result=$( printf "%d + %d" 0x0x000 0x00046b3e ) # check
echo $result
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|