Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Converting decimal to/from IEEE hex format

  • To: mathgroup at
  • Subject: [mg71239] Re: [mg71206] Converting decimal to/from IEEE hex format
  • From: Carl Woll <carlw at>
  • Date: Sat, 11 Nov 2006 03:38:58 -0500 (EST)
  • References: <>

Robert wrote:

>Can anyone tell me how to convert a number to/from the corresponding
>IEEE hex floating-point representation in either 32 or 64 bits in
>Mathematica?  For
>example, I would want to convert 1.0 into 3F800000 (32-bit) or
>3FF0000000000000 (64-bit), and vice-versa.  (When converting from
>decimal to hex, if the number is not exactly representable, I would
>want the nearest floating-point number.)  Thanks, Robert
One idea is to use BinaryWrite and BinaryRead, although that requires 
the use of external files. Here is one implementation:


RealToHex32[1.0] // OutputForm

The conversion backwards needs a design decision on what format you want 
the hex representation to be in.

Carl Woll
Wolfram Research

  • Prev by Date: Re: I could do with a list of geometric shape names can anyone help????
  • Next by Date: Re: Re: Simplifying in Mathematica
  • Previous by thread: Converting decimal to/from IEEE hex format
  • Next by thread: Re: Re: Converting decimal to/from IEEE hex format