简体   繁体   中英

How can I produce the exact decimal values

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM