在一定限制后以指数形式显示数字,也限制小数点后的位数 [英] to display number in exponential form after certain limit also limit number of digit after decimal

查看:80
本文介绍了在一定限制后以指数形式显示数字,也限制小数点后的位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为不同的单位制作转换工具,如果它们超过1000,我想以指数形式显示数字(例如,如果I/O 10001然后O/P 1.000E + 04,如果I/O 1000.1然后O/P 1.000E + 03).对于小于1的数字也是如此(如果I/O 0.001,则O/P 1.000E-03,如果I/O 9.84203533290685E-04,则O/P 9.842E-04.

抱歉,如果qusetion非常简单,但是我是VB .net的新手并且对数学非常不好.

I am trying to make a conversion tool for different units where i want to display number in exponential form if they exceed 1000(for eg if I/O 10001 then O/P 1.000E+04, if I/O 1000.1 then O/P 1.000E+03).Also for numbers less than 1 (if I/O 0.001 then O/P 1.000E-03, if I/O 9.84203533290685E-04 then O/P 9.842E-04.

Sorry if the qusetion is very simple but I am new to VB .net and pretty bad with maths.

推荐答案

您可以在数字上使用ToString进行设置"的格式为字符串.十进制d = 23.55454 d.ToString("N2")将显示两个小数位. d.ToString("e")将显示科学计数法.

数学与它无关.
You can use ToString on your number to set it''s format as a string. Decimal d = 23.55454 d.ToString("N2") will show two decimal places. d.ToString("e") will show scientific notation.

Maths has nothing to do with it.


这篇关于在一定限制后以指数形式显示数字,也限制小数点后的位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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