如何获得小数位数nr [英] how to get nr of fraction digits

查看:69
本文介绍了如何获得小数位数nr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


有人知道如何获得小数位数的简单方法吗?


示例:

1.23会得到2

1.234会得到3

的结果是

我知道我可以拆分小数分隔符上的数字,然后计算结果数组的第二部分中的

字符,但我想,那么

应该是另一种解决方案吗?


任务应该很简单,但我正在寻找各种系统数学

课程,但我没有看到它...


或者我应该选择拆分方法吗? :-)

问候


米歇尔

解决方案

什么可以更简单比< variable> .ToString.Split("。" c)(1).Length?


是什么让你认为应该有另一种解决方案?


" Michel Posseth [MCP]" < Mi ************** @ discuss.microsoft.com写在

消息新闻:62 ************** ******************** @ microsof t.com ...


您好,


有人知道如何获得小数位数的简单方法




例如:

1.23将得到2

1.234将得到3的结果




我知道我可以在小数分隔符上拆分数字,然后在结果数组的第二部分中计算

字符,但我想,

那里

应该是另一种解决方案吗?


任务应该很简单,但我正在寻找各种系统数学

课程,但我没有看到它...


或我应该去分裂方法? :-)


问候


米歇尔


< blockquote> Hello Stephany,


well


Dim decval As Decimal = CDec(1.23)


MsgBox(decval.ToString.Split(CChar(System.Globaliz ation.NumberFormatInfo.CurrentInfo.NumberDecimalSe parator))(1).Length())


工作正常但我应该还要检查可能发生的异常


i只是认为这种看似有内置的方法通常是b $ b和简单。任务


Michel Posseth



" Stephany Young"写道:


什么可能比< variable> .ToString.Split("。" c)(1).Length?
<更简单br />
是什么让你认为应该有另一种解决方案?


Michel Posseth [MCP]" < Mi ************** @ discuss.microsoft.com写在

消息新闻:62 ************** ******************** @ microsof t.com ...


您好,


有人知道如何获得小数位数的简单方法




例如:

1.23会得到2

1.234会得到3

的结果是

我知道我可以分割数字在小数分隔符上,然后在结果数组的第二部分中计算



字符,但我想,



应该是另一个解决方案吗?


任务应该很简单,但我正在寻找各种系统数学

课程,但我是没有看到它...


或者我应该选择拆分方法吗? :-)

问候


米歇尔



< blockquote>没有人?


没有人知道不同的做法吗?

" Michel Posseth [MCP]" < Mi ************** @ discussion.microsoft.comschre ef

bericht新闻:87 ************* ********************* @ microsof t.com ...


Hello Stephany,


well


Dim decval As Decimal = CDec(1.23)

MsgBox(decval.ToString。拆分(CChar(System.Globaliz ation.NumberFormatInfo.CurrentInfo.NumberDecimalSe parator))(1).Length())


工作正常,但我也应检查可能发生的异常


i只是觉得这个貌似会有一个内置的方法,而且简单是简单的。任务


Michel Posseth



" Stephany Young"写道:


>什么可能比< variable> .ToString.Split("。" c)(1).Length更简单?

是什么让你认为应该有另一种解决方案?

Michel Posseth [MCP]" < Mi ************** @ discussion.microsoft.comwrote
在消息新闻中:62 ************** ******************** @ microsof t.com ...


您好,


有人知道如何获得nr分数的简单方法

位数




例如:

1.23会得到2

1.234会得到3




我知道我可以在小数分隔符上拆分数字,然后在结果数组的第二部分中计算

字符

字符,但我想, ,

那里

应该是另一种解决方案?


任务应该很简单,但我正在寻找各种系统数学

班级,但我没有看到它......


或者我应该选择拆分方法吗? :-)


问候


米歇尔




Hello ,

Does someone knows a simple way of how to get the nr of fraction digits ?

example :
1.23 would give a result of 2
1.234 would give a result of 3
Yes
I know i could split the number on the decimal seperator and then count the
characters in the second part of the resulting array , but i thought ,, there
should be another solution ?

the task should be simple but i am looking in all sorts of system math
classes but i am not seeing it ...

or should i go for the split method ? :-)
regards

Michel

解决方案

What could be simpler than <variable>.ToString.Split("."c)(1).Length?

What makes you think that there ''should'' be another solution?

"Michel Posseth [MCP]" <Mi**************@discussions.microsoft.comwrote in
message news:62**********************************@microsof t.com...

Hello ,

Does someone knows a simple way of how to get the nr of fraction digits
?

example :
1.23 would give a result of 2
1.234 would give a result of 3
Yes
I know i could split the number on the decimal seperator and then count
the
characters in the second part of the resulting array , but i thought ,,
there
should be another solution ?

the task should be simple but i am looking in all sorts of system math
classes but i am not seeing it ...

or should i go for the split method ? :-)
regards

Michel


Hello Stephany ,

well

Dim decval As Decimal = CDec(1.23)

MsgBox(decval.ToString.Split(CChar(System.Globaliz ation.NumberFormatInfo.CurrentInfo.NumberDecimalSe parator))(1).Length())

works fine however , i should also check for exceptions that might occur

i just thought that there would be a built in method for this seemingly
common and "simple" task

Michel Posseth



"Stephany Young" wrote:

What could be simpler than <variable>.ToString.Split("."c)(1).Length?

What makes you think that there ''should'' be another solution?

"Michel Posseth [MCP]" <Mi**************@discussions.microsoft.comwrote in
message news:62**********************************@microsof t.com...

Hello ,

Does someone knows a simple way of how to get the nr of fraction digits
?

example :
1.23 would give a result of 2
1.234 would give a result of 3
Yes
I know i could split the number on the decimal seperator and then count
the
characters in the second part of the resulting array , but i thought ,,
there
should be another solution ?

the task should be simple but i am looking in all sorts of system math
classes but i am not seeing it ...

or should i go for the split method ? :-)
regards

Michel



Nobody ??

Nobody who knows a different way of doing this ?
"Michel Posseth [MCP]" <Mi**************@discussions.microsoft.comschre ef
in bericht news:87**********************************@microsof t.com...

Hello Stephany ,

well

Dim decval As Decimal = CDec(1.23)

MsgBox(decval.ToString.Split(CChar(System.Globaliz ation.NumberFormatInfo.CurrentInfo.NumberDecimalSe parator))(1).Length())

works fine however , i should also check for exceptions that might occur

i just thought that there would be a built in method for this seemingly
common and "simple" task

Michel Posseth



"Stephany Young" wrote:

>What could be simpler than <variable>.ToString.Split("."c)(1).Length?

What makes you think that there ''should'' be another solution?

"Michel Posseth [MCP]" <Mi**************@discussions.microsoft.comwrote
in
message news:62**********************************@microsof t.com...

Hello ,

Does someone knows a simple way of how to get the nr of fraction
digits
?

example :
1.23 would give a result of 2
1.234 would give a result of 3
Yes
I know i could split the number on the decimal seperator and then count
the
characters in the second part of the resulting array , but i thought ,,
there
should be another solution ?

the task should be simple but i am looking in all sorts of system math
classes but i am not seeing it ...

or should i go for the split method ? :-)
regards

Michel




这篇关于如何获得小数位数nr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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