[AccessD] [dba-VB] C#, mantissa, math fun

Gustav Brock gustav at cactus.dk
Sun Oct 15 10:54:07 CDT 2017


Hi all

I posted a method for this in C#.
Finding the mantissa in VBA it could be like:

<code>
' Returns the mantissa of a decimal number as
' a string to preserve leading zeroes.
'
' Examples:
'   Mantissa(1234.56789)    -> "56789"
'   Mantissa(-1234.56789)   -> "56789"
'   Mantissa(1234.056789)   -> "056789"
'   Mantissa(-1234.056789)  -> "056789"
'   Mantissa(123456789)     -> ""
'
' 2017-10-15. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function Mantissa( _
    ByVal Number As Double) _
    As String

    Dim Result      As String
    Dim Fraction    As Variant

    Fraction = CDec(Number) - CDec(Fix(Number))

    If Fraction <> 0 Then
        Result = Mid(Str(Abs(Fraction)), 3)
    End If

    Mantissa = Result

End Function
</code>

/gustav



More information about the AccessD mailing list