我该如何获得后在VB.NET一个小数点的数字小数点、我该、如何获得、数字

2023-09-04 01:24:37 作者:智者永不坠入爱河

谁能给我一个简单的方法来找出双重的小数点后的数字? 所有我需要做的是找出如果数字0结尾像1.0或10.0或323.0?

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 323.0 ?

你有没有这方面有任何想法?

Have you any idea about this?

推荐答案

如果您正在使用的任何数值数据类型(如双,单,整数,小数),则无法重新present 10.0和10两个不同而不同的值。有没有办法做到这一点。如果你需要保持数的尾数,即使是零,你将不得不存储值一些其他的数据类型,如字符串。

If you are using any of the numeric data types (e.g. double, single, integer, decimal), you cannot represent 10.0 and 10 as two different and distinct values. There is no way to do that. If you need to keep the mantissa of the number, even when it is zero, you will have to store the value as some other data type such as a string.

要验证已输入的字符串,你可以做这样的事情:

To validate a string that has been entered, you could do something like this:

Public Function MantissaIsZero(ByVal value As String) As Boolean
    Dim result As Boolean = False
    Dim parts() As String = value.Split("."c)
    If parts.Length = 2 Then
        Dim mantissa As Integer = 0
        If Integer.TryParse(parts(1), mantissa) Then
            result = (mantissa = 0)
        End If
    End If
    Return result
End Function