Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Converting Hex to Float (and vise versa)

by barrachois (Pilgrim)
on Feb 09, 2004 at 21:51 UTC ( #327754=note: print w/replies, xml ) Need Help??

in reply to Converting Hex to Float (and vise versa)

I would think the simplest is to let Perl do the work for you. Since 0x428C0000 is an allowed number format in Perl, just evaluate the string using eval() and let Perl translate it into a number for you.

This trick will also work for the other allowed number formats, such as 0777 (leading 0 implies octal).

For example,

print " $_ is " . eval($_) . "\n" for qw( 0x428C000 0777 );
I put together a CGI script to do this sort of conversion (and a few other IP network translations) which you might find instructive; see this link and the source code. Feel free to adopt as you see fit.

- barrachois

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://327754]
[Corion]: Oh yay. $project has faffed around for 2 years and now pushed a hasty 2 weeks solution into production without telling me. Of course, the new data also needs changes on my side to be processed correctly. Now they try to raise incidents against my ...
[Corion]: ... input systems to make the change outside of the organized project because I don't have ressources for the project to make the change.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-08-17 09:08 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (285 votes). Check out past polls.