想要在C#中找到Double值的长度 [英] Want to find the length of Double value in C#

查看:446
本文介绍了想要在C#中找到Double值的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#中查找特定double值的长度.

我是新手,我不知道如何找到双精度值的长度.

例如;

I want to find the length of particular double value in C#.

I''m novice, I dont know how to find the length of double value.

For example;

double sample1;
sample1=123;
int size;
size = //size of double value, that is 3.



如何找到双精度值的大小?



how can i find the size of double value?

thanks in advance.

推荐答案

使用以下代码:
Use below code:
double sample1;
sample1 = 123;
int size;
size = sample1.ToString().Length;






Or

int size = de.ToString().Remove(de.ToString().IndexOf('.')).Length;


使用此方法:
Use this :
double de = 12345;
int len = (int)Math.Ceiling(Math.Log10(de));


这篇关于想要在C#中找到Double值的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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