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. 基于CentOS 搭建 Seafile 专属网盘

    系统要求:CentOS 7.2 64 位操作系统 安装 Seafile 安装依赖环境 使用 yum 安装 Python 及 MySQL: yum install python python-setup ...

  2. 11G新特性 -- flashback data archive(1)

    虽然可以依赖undo数据来查询row的旧版本数据,甚至可以执行逻辑恢复.但是你不能期待在undo中找到非常旧的数据.undo数据主要是用来提供读一致性. 在11G中,提供了Flashback Data ...

  3. 在代码中设置RelativeLayout布局中标签的android:layout_toLeftOf、android:layout_toRightOf等属性

    需要动态改变RelativeLayout里面控件的相对位置,经一个技术群的群友提示,找到了如下的方法,做下记录:   RelativeLayout.Layoutparams params = (Rel ...

  4. 电子证书 DER & PEM & CRT & CER

    原文链接: http://blog.csdn.net/zqt520/article/details/26966603 证书与编码 本至上,X.509证书是一个数字文档,这个文档根据RFC 5280来编 ...

  5. 使用Python解析JSON详解

    为大家介绍如何使用 Python 语言来编码和解码 JSON 对象. JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,易于人阅读和编写. JSON 函数 ...

  6. linux source code search

    https://elixir.bootlin.com/linux/latest/source/fs/eventpoll.c#L1120

  7. 微信小程序--兼容

    小程序的功能不断的增加,但是旧版本的微信客户端并不支持新功能,所以在使用这些新能力的时候需要做兼容. 文档会在组件,API等页面描述中带上各个功能所支持的版本号. 可以通过 wx.getSystemI ...

  8. 【转】Django中使用POST方法获取POST数据

    1.获取POST中表单键值数据 如果要在django的POST方法中获取表单数据,则在客户端使用JavaScript发送POST数据前,定义post请求头中的请求数据类型: xmlhttp.setRe ...

  9. idea 导入 android项目

    1. 2. 主要是勾选上面选项. next next 导入即可

  10. Viewing the interface of your Swift code,查看Swift代码的头文件的三种方法

      Technical Q&A QA1914 Viewing the interface of your Swift code Q:  How do I view the interface ...