Vb.net mantissa and counting exhibitors from double

Can anyone offer any advice on how to get a mantissa and an exhibitor from a double in VB.net? I know that I can do string parsing and some conversion to ints, but I thought if anyone had a mathematical equivalent formula that would allow me to do this?

Many thanks

+3
source share
2 answers

Do you want to get the native mantissa and exponent within the IEEE-754 value? It's actually quite simple: use BitConverter.DoubleToInt64Bitsto get the value as an integer (which is easier to perform bitwise operations), and then see mine about .NET binary floating-point types for which there are bits.

I have C # code that extracts various parts to convert it to an exact decimal representation - you could convert the corresponding bits to that in VB quite easily.

+2
source

You should try the following:

Public Function DeclString(ByVal dDegrees As Double) As String
   Dim Flag As String
   Dim ddecimal As Double
   Dim iDegrees As Integer
   If dDegrees < 0 Then Flag = "S" Else Flag = "N"
   iDegrees = Int(Abs(dDegrees))
   ddecimal = (Abs(dDegrees) - iDegrees) * 60 ' + 0.5
   If ddecimal > 59.5 Then iDegrees = iDegrees + 1: ddecimal = 0
   DeclString = Format$(iDegrees, "00") + Flag + Format$(ddecimal, "00")
End Function
0
source

Source: https://habr.com/ru/post/1770064/


All Articles