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 nnnExxnnnE+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 true.

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 true.

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 AllowLeadingWhiteAllowTrailingWhiteAllowLeadingSignAllowDecimalPoint, and AllowExponent styles are used. This is a composite number style.

HexNumber 515

Indicates that the AllowLeadingWhiteAllowTrailingWhite, and AllowHexSpecifier styles are used. This is a composite number style.

Integer 7

Indicates that the AllowLeadingWhiteAllowTrailingWhite, 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 AllowLeadingWhiteAllowTrailingWhiteAllowLeadingSignAllowTrailingSignAllowDecimalPoint, and AllowThousands styles are used. This is a composite number style.

[No0000164]C#,科学计数法的哽的更多相关文章

  1. csv 中 数值被自动转换成科学计数法 的问题 excel打开后数字用科学计数法显示且低位变0的解决方法

    保存在csv中的 013812345678,前面的0会被去掉,后面是科学计数法显示.保存成 col1,="013812345678" 即可. 注意,分隔符逗号后面直接接“=”等号. ...

  2. 【转】js 中导出excel 较长数字串会变为科学计数法

    [转]js 中导出excel 较长数字串会变成科学计数法 在做项目中,碰到如题的问题.比如要将居民的信息导出到excel中,居民的身份证号码因为长度过长(大于10位),excel会自动的将过长的数字串 ...

  3. C# 科学计数法转换成数字

    /// <summary> /// 判断输入的数是否是科学计数法.如果是的话,就会将其换算成整数并且返回,否则就返回false. /// </summary> /// < ...

  4. C# 中科学计数法转成正常值

    抓取数据的时候碰到科学技术法,查了一些资料,直接贴代码 /// <summary> /// 数字科学计数法处理 /// </summary> /// <param nam ...

  5. PAT 1024. 科学计数法 (20)

    科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+-][0-9]+,即数字的整数部分只有1位,小数部分至少有1位 ...

  6. PHP 如何显示大数字,防止显示为 科学计数法 形式

    PHP 数字超过一定长度时,会自动转换为 科学计数法 的形式,如 1.2345678912346E+16: 如何 避免转换,让它原样展示呢? 不过,可以用PHP函数 number_format() 来 ...

  7. 关于解决读取导入excel某列数字过长的科学计数法格式

    因为 客户 需要导入 虚拟商品的卡号 excel已经是文本形式的单元格格式了 但是 到后台 java代码去获取的时候 仍然是 科学计数法格式 先找到以下资料做参考:http://love-66521. ...

  8. PAT乙级 1024. 科学计数法 (20)

    1024. 科学计数法 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 HOU, Qiming 科学计数法是科学家用来表示很 ...

  9. POI取消科学计数法

    前台输入手机号13777777777,如果是为Double类型接收,就会自动转为科学计数法 找了下,一般是Double转String,方法一般有两种: 1.利用String.format() sale ...

随机推荐

  1. OpenLayers典型部分概述

    中文学习:http://www.openlayers.cn/portal.php 原文地址:https://www.jianshu.com/p/e693711a7008 一 OpenLayers核心职 ...

  2. CorelCAD for Mac(绘图设计软件)破解版安装

    1.软件简介    CorelCAD 是 macOS 系统上的 CAD 绘图工具,为我们提供了获取本地 DWG 格式的高性能 CAD 设计解决方案.打开.处理和保存 .DWG 文件,实现轻松协作.借助 ...

  3. Mac下必备快捷键的符号所对应的按键

    Mac下快捷键的符号所对应的按键 ⌥—> option|alt ⇧—>shift ⌃—>control ⌘—>command ⎋—>esc 注: 与F6/F7/F12等F ...

  4. 升级python(linux)

    查看系统当前python版本 2: [root@wangyuelou ~]# python     Python 2.4.3 (#1, May  5 2011, 16:39:10)     [GCC ...

  5. 专访图书作者祁宇:C++11让程序更简洁、更现代、更强大

    日前CSDN采访了祁宇,请他解读C++11的新标准.C++的现状以及未来的发展前景. CSDN:怎么会想到编写<深入应用C++11:代码优化与工程级应用>这本书的?有没有什么故事可以分享下 ...

  6. 每日英语:Dashing the China Dream

    Much has been said about what the 'China Dream' really means to many Chinese -- whether it is nation ...

  7. linux每日命令(13):more命令

    more命令,功能类似 cat ,cat命令是整个文件的内容从上到下显示在屏幕上. more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会 ...

  8. linux每日命令(30):Linux 用户及用户组相关文件、命令详解

    一. 用户.用户组概念及其文件结构详解 Linux用户只有两个等级:root及非root.Linux中还有一部分用户,如:apache.mysql.nobody.ftp等,这些也都是非root用户,即 ...

  9. linux每日命令(37):top命令

    top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器.下面详细介绍它的使用方法.top是一个动态显示过程,即可以通过用户按键来不断刷新 ...

  10. 【iCore4 双核心板_ARM】例程二十三:LWIP_HTTP实验——网页服务器

    实验现象: 核心代码: int main(void) { system_clock.initialize(); led.initialize(); adc.initialize(); delay.in ...