[No0000164]C#,科学计数法的哽
NewString = Decimal.Parse(OldString, System.Globalization.NumberStyles.Float).ToString();
//Convert.ToDecimal(Decimal.Parse(OldString, System.Globalization.NumberStyles.Float)).ToString();
public abstract class ScienceCount
{
public static string Exponent(double num)
{
double before =System.Math.Abs(num);
int after=;
while (before >= ||(before < && before!=))
{
if (before >= )
{
before = before / ;
after++;
}
else
{
before = before * ;
after--;
}
}
return string.Concat(num>=?"":"-",ReturnBefore(before),"E",ReturnAfter(after));
}
/// <summary>
/// 有效数字的处理
/// </summary>
/// <param name="before">有效数字</param>
/// <returns>三位有效数字,不足则补零</returns>
public static string ReturnBefore(double before)
{
if (before.ToString() != null)
{
char[] arr = before.ToString().ToCharArray();
switch (arr.Length)
{
case :
case : return string.Concat(arr[] , "." , ""); break;
case : return string.Concat(arr[] + "." + arr[] + ""); break;
default: return string.Concat(arr[] + "." + arr[] + arr[]); break;
}
} return "";
}
/// <summary>
/// 幂的处理
/// </summary>
/// <param name="after">幂数</param>
/// <returns>三位幂数部分,不足则补零</returns>
public static string ReturnAfter(int after)
{
if (after.ToString() != null)
{
string end;
char[] arr = System.Math.Abs(after).ToString().ToCharArray();
switch (arr.Length)
{
case : end = "" + arr[]; break;
case : end = "" + arr[] + arr[]; break;
default: end = System.Math.Abs(after).ToString(); break;
}
return string.Concat(after >= ? "+" : "-" , end);
} return "+000";
}
}
OldString = double.Parse(NewString).ToString("E");
AllowCurrencySymbol | 256 |
Indicates that the numeric string can contain a currency symbol. Valid currency symbols are determined by the CurrencySymbol property. |
AllowDecimalPoint | 32 |
Indicates that the numeric string can have a decimal point. If the NumberStyles value includes the AllowCurrencySymbol flag and the parsed string includes a currency symbol, the decimal separator character is determined by the CurrencyDecimalSeparator property. Otherwise, the decimal separator character is determined by the NumberDecimalSeparator property. |
AllowExponent | 128 |
Indicates that the numeric string can be in exponential notation. The AllowExponent flag allows the parsed string to contain an exponent that begins with the "E" or "e" character and that is followed by an optional positive or negative sign and an integer. In other words, it successfully parses strings in the form nnnExx, nnnE+xx, and nnnE-xx. It does not allow a decimal separator or sign in the significand or mantissa; to allow these elements in the string to be parsed, use the AllowDecimalPoint and AllowLeadingSign flags, or use a composite style that includes these individual flags. |
AllowHexSpecifier | 512 |
Indicates that the numeric string represents a hexadecimal value. Valid hexadecimal values include the numeric digits 0-9 and the hexadecimal digits A-F and a-f. Strings that are parsed using this style cannot be prefixed with "0x" or "&h". A string that is parsed with the AllowHexSpecifier style will always be interpreted as a hexadecimal value. The only flags that can be combined with AllowHexSpecifier are AllowLeadingWhite and AllowTrailingWhite. The NumberStyles enumeration includes a composite style, HexNumber, that consists of these three flags. |
AllowLeadingSign | 4 |
Indicates that the numeric string can have a leading sign. Valid leading sign characters are determined by the PositiveSign and NegativeSign properties. |
AllowLeadingWhite | 1 |
Indicates that leading white-space characters can be present in the parsed string. Valid white-space characters have the Unicode values U+0009, U+000A, U+000B, U+000C, U+000D, and U+0020. Note that this is a subset of the characters for which the IsWhiteSpace(Char) method returns |
AllowParentheses | 16 |
Indicates that the numeric string can have one pair of parentheses enclosing the number. The parentheses indicate that the string to be parsed represents a negative number. |
AllowThousands | 64 |
Indicates that the numeric string can have group separators, such as symbols that separate hundreds from thousands. If the NumberStyles value includes the AllowCurrencySymbol flag and the string to be parsed includes a currency symbol, the valid group separator character is determined by the CurrencyGroupSeparator property, and the number of digits in each group is determined by the CurrencyGroupSizes property. Otherwise, the valid group separator character is determined by the NumberGroupSeparator property, and the number of digits in each group is determined by the NumberGroupSizes property. |
AllowTrailingSign | 8 |
Indicates that the numeric string can have a trailing sign. Valid trailing sign characters are determined by the PositiveSign and NegativeSign properties. |
AllowTrailingWhite | 2 |
Indicates that trailing white-space characters can be present in the parsed string. Valid white-space characters have the Unicode values U+0009, U+000A, U+000B, U+000C, U+000D, and U+0020. Note that this is a subset of the characters for which the IsWhiteSpace(Char) method returns |
Any | 511 |
Indicates that all styles except AllowHexSpecifier are used. This is a composite number style. |
Currency | 383 |
Indicates that all styles except AllowExponent and AllowHexSpecifier are used. This is a composite number style. |
Float | 167 |
Indicates that the AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign, AllowDecimalPoint, and AllowExponent styles are used. This is a composite number style. |
HexNumber | 515 |
Indicates that the AllowLeadingWhite, AllowTrailingWhite, and AllowHexSpecifier styles are used. This is a composite number style. |
Integer | 7 |
Indicates that the AllowLeadingWhite, AllowTrailingWhite, and AllowLeadingSign styles are used. This is a composite number style. |
None | 0 |
Indicates that no style elements, such as leading or trailing white space, thousands separators, or a decimal separator, can be present in the parsed string. The string to be parsed must consist of integral decimal digits only. |
Number | 111 |
Indicates that the AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign, AllowTrailingSign, AllowDecimalPoint, and AllowThousands styles are used. This is a composite number style. |
[No0000164]C#,科学计数法的哽的更多相关文章
- csv 中 数值被自动转换成科学计数法 的问题 excel打开后数字用科学计数法显示且低位变0的解决方法
保存在csv中的 013812345678,前面的0会被去掉,后面是科学计数法显示.保存成 col1,="013812345678" 即可. 注意,分隔符逗号后面直接接“=”等号. ...
- 【转】js 中导出excel 较长数字串会变为科学计数法
[转]js 中导出excel 较长数字串会变成科学计数法 在做项目中,碰到如题的问题.比如要将居民的信息导出到excel中,居民的身份证号码因为长度过长(大于10位),excel会自动的将过长的数字串 ...
- C# 科学计数法转换成数字
/// <summary> /// 判断输入的数是否是科学计数法.如果是的话,就会将其换算成整数并且返回,否则就返回false. /// </summary> /// < ...
- C# 中科学计数法转成正常值
抓取数据的时候碰到科学技术法,查了一些资料,直接贴代码 /// <summary> /// 数字科学计数法处理 /// </summary> /// <param nam ...
- PAT 1024. 科学计数法 (20)
科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+-][0-9]+,即数字的整数部分只有1位,小数部分至少有1位 ...
- PHP 如何显示大数字,防止显示为 科学计数法 形式
PHP 数字超过一定长度时,会自动转换为 科学计数法 的形式,如 1.2345678912346E+16: 如何 避免转换,让它原样展示呢? 不过,可以用PHP函数 number_format() 来 ...
- 关于解决读取导入excel某列数字过长的科学计数法格式
因为 客户 需要导入 虚拟商品的卡号 excel已经是文本形式的单元格格式了 但是 到后台 java代码去获取的时候 仍然是 科学计数法格式 先找到以下资料做参考:http://love-66521. ...
- PAT乙级 1024. 科学计数法 (20)
1024. 科学计数法 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 HOU, Qiming 科学计数法是科学家用来表示很 ...
- POI取消科学计数法
前台输入手机号13777777777,如果是为Double类型接收,就会自动转为科学计数法 找了下,一般是Double转String,方法一般有两种: 1.利用String.format() sale ...
随机推荐
- LightCapture for Mac(流程化截图工具)破解版安装
1.软件简介 LightCapture 是 macOS 系统上的截图软件.LightCapture Mac 版号称是用最简洁的方式来截图,其的界面也确实非常简单整洁,不过功能同样出色,一键截屏. ...
- PyCharm for Mac(Python 开发工具)破解版安装
1.软件简介 PyCharm 是 macOS 系统上一款 Python 编辑利器,具有智能代码编辑器,能理解 Python 的特性并提供卓越的生产力推进工具:自动代码格式化.代码完成.重构.自动 ...
- ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
开发说测试环境在删除表的时候,报了如下错误: SQL> drop table tke purge; drop table tke purge * ERROR at line 1: ORA-000 ...
- Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name
启动apache的时候,报告以下消息提示: Starting httpd: httpd: Could not reliably determine the server's fully qualifi ...
- KVM上如何让虚拟机支持虚拟化(kvm虚拟化的嵌套)
http://blog.csdn.net/swimming_in_it_/article/details/53320141http://blog.csdn.net/wickedglory/articl ...
- 自动化CodeReview - ASP.NET Core依赖注入
自动化CodeReview系列目录 自动化CodeReview - ASP.NET Core依赖注入 自动化CodeReview - ASP.NET Core请求参数验证 我个人比较懒,能自动做的事绝 ...
- 【Spark 深入学习 02】- 我是一个凶残的spark
学一门新鲜的技术,其实过程都是相似的,先学基本的原理和概念,再学怎么使用,最后深究这技术是怎么实现的,所以本章节就带你认识认识spark长什么样的,帅不帅,时髦不时髦(这货的基本概念和原理),接着了解 ...
- WebSphere集群环境修改IHS端口号的方法 分类: WebSphere 2015-08-06 13:41 14人阅读 评论(0) 收藏
参考资料:http://wenku.baidu.com/link?url=E9BkuEjJ16i9lg7l91L0-xhKCYkHV0mAnlwAeSlDCFM4TjZyk4ZVxmUu64BGd4F ...
- Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please ...
- System.Runtime.InteropServices.COMException 检索COM类工厂中CLSID{xxxxxxxxx}的组件时失败解决方法
iis7.5中设定应用程序池中<进程模型>中<标识>为localSystem 提示:System.Runtime.InteropServices.COMException: 命 ...