TechArena Community Converting the floating point number to the hexadecimal on the Microsoft Excel 2010

#1
10-07-2011
 Member Join Date: Jun 2006 Posts: 65
Converting the floating point number to the hexadecimal on the Microsoft Excel 2010

I had recently upgraded to Microsoft Office 2010 on my system. I want some help to I convert the floating number into hex representation. I am unable to find any option to do the same. I am having a series of excel sheet which has this digits in it. I am not able to find any third party plugin also that can provide me option to convert the floating point to hexadecimal. I hope this might be working.
#2
10-07-2011
 Member Join Date: Jun 2009 Posts: 1,518
Re: Converting the floating point number to the hexadecimal on the Microsoft Excel 2010

Excel supports a HEX2DEC function. I am going to give you a link below which gives you enough information through which you can use this function. In the below link at the end you can find some formula that can help you what you are looking for. Just visit the link and see whether you are able to get a proper solution or not.

HEX2DEC function
#3
10-07-2011
 Member Join Date: Nov 2008 Posts: 1,514
Re: Converting the floating point number to the hexadecimal on the Microsoft Excel 2010

Well looking at the requirement of yours I am suggesting following code which you can run and see whether it is helpful to you.

Code:
```Function Sng2String(s As Single) As String
' shg 2008-0919

' Returns the conversion of float s to a hex string

Const sPad As String = "00000000"
Dim uf As uFlt
Dim ul As uLng

uf.f = s
LSet ul = uf
Sng2String = Right(sPad & Hex(ul.l), 8)
End Function```
#4
10-07-2011
 Member Join Date: Mar 2009 Posts: 1,360
Re: Converting the floating point number to the hexadecimal on the Microsoft Excel 2010

I am posting following code which you can convert the decimal fraction to the hexadecimal fraction.
Code:
`="0." & DEC2HEX(B1*16^B2)`
Here the decimal fraction is B1 and B2 which is defining the number of the hexadecimal plces into the output. So try the function which I have mentioned over here I am hoping that it would be useful to get the requirement of yours.
#5
10-07-2011
 Member Join Date: Nov 2008 Posts: 1,259
Re: Converting the floating point number to the hexadecimal on the Microsoft Excel 2010

Well I am posting below all the routines which are implemented into the situation of yours which would give you light shed on this particular matter.
Code:
```'   shg 2008-0919
'       2009-0517 minor internal changes
'       2010-0306 added DblMan & DblExp functions
'       2010-0331 added DbltoBin & Byte2Bin functions

'   Routine             Input                   Output             UDF/VBA
'   --------    -------------------- ---------------------------- -------
'   Byte2Sng    ab(0 To 3)           Single                       VBA
'   Sng2Byte    Single               4-byte array Variant         Both
'   Sng2Hex     Single               Hex String                   Both
'   Hex2Sng     Hex string           Single                       Both
'   Var2Sng     4-byte array Variant Single                       Both

'   Routine            Input                   Output             UDF/VBA
'   --------    -------------------- ---------------------------- -------
'   Byte2Dbl    ab(0 To 7)           Double                       VBA
'   Dbl2Byte    Double               8-byte array Variant         Both
'   Dbl2Hex     Double               Hex string                   Both
'   Dbl2Bin     Double               Signed binary decimal string Both
'   Hex2Dbl     Hex string           Double                       Both
'   Var2Dbl     8-byte array Variant Double                       Both
'   DblMan      Double               Double (mantissa of input)   Both
'   DblExp      Double               Long (exponent of input)     Both
'   IntStr2Bin  Decimal string       64-bit binary string         Both

'   Routine            Input                   Output             UDF/VBA
'   --------    -------------------- ---------------------------- -------
'   Flt2Byte    Single or Double     4- or 8-byte array Variant   VBA
'   Byte2Hex    Byte array           Hex string                   VBA
'   Byte2Bin    Byte array           Binary string                VBA```
#6
11-07-2011
 Member Join Date: Nov 2008 Posts: 1,185
Re: Converting the floating point number to the hexadecimal on the Microsoft Excel 2010

Let me know whether any of the above mentioned thing worked for you or not. If you have not managed to get the requirement of yours then you should use the below mentioned formula and let me know about the results.
Code:
`=Sng2String(3.4E+38)`

 Tags:

 Similar Threads for: "Converting the floating point number to the hexadecimal on the Microsoft Excel 2010" Thread Thread Starter Forum Replies Last Post Converting GPS Co-ordination in Microsoft Excel Kumar esan MS Office Support 2 15-02-2012 08:08 PM floating point issue.Why is it so? maria_megha Software Development 1 23-07-2011 04:00 AM VLC 1.1.7/openSUSE 11.3 having Floating point exception problem Bryant Windows Software 6 12-07-2011 11:14 AM Filenames appear as hexadecimal code in excel ? Tufan Windows Software 3 26-11-2010 06:17 AM How to correct Rounding Errors in Floating Point Arithmetic? Vandam Windows Software 5 11-03-2010 05:11 AM

All times are GMT +5.5. The time now is 06:24 PM.