How would I get the number after a decimal point in VB.NET

后端 未结 8 1918
猫巷女王i
猫巷女王i 2021-01-27 12:10

Can anyone give me an easy way to find out the numbers after the decimal point of the double?
All i need to do is to find out if the number ends in 0 like 1.0 or 10.0 or 32

8条回答
  •  说谎
    说谎 (楼主)
    2021-01-27 12:45

    What you need to do is multiply by 10 and then mod 10.

    For instance. lets say x = 10.2

    temp = x * 10 ' temp equals 102

    temp = temp % 10 ' that should return the 2. Temp is now the value of the decimal you need.

    This should work for negative values as well.

    If you need to compare to see if it is a 0, all you do is compare your temp var to 0.

提交回复
热议问题