Home > Net >  How can I produce the exact decimal values
How can I produce the exact decimal values

Time:11-25

Code:

Dim mp as Decimal

mp = 2056834 / 36 MsgBox(mp, vbInformation)

Output: 57134.2777777778

I was expecting the output to be:

Output: 57134.27777777778

What suppose to be the problem on why it was short of a decimal point?

CodePudding user response:

Try this:

Dim mp As Decimal

mp = Math.Round(CDec(2056834) / CDec(36), 11)
MsgBox(mp, vbInformation)

This will produce the expected output: 57134.27777777778

  • Related