我该如何获得后在VB.NET一个小数点的数字 [英] How would I get the number after a decimal point in VB.NET

查看:341
本文介绍了我该如何获得后在VB.NET一个小数点的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我一个简单的方法来找出双重的小数点后的数字?
所有我需要做的是找出如果数字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

这篇关于我该如何获得后在VB.NET一个小数点的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆