[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 ...
随机推荐
- 译: 2. RabbitMQ Spring AMQP 之 Work Queues
在上一篇博文中,我们写了程序来发送和接受消息从一个队列中. 在这篇博文中我们将创建一个工作队列,用于在多个工作人员之间分配耗时的任务. Work Queues 工作队列(又称:任务队列)背后的主要思想 ...
- [k8s] 最简单的集群小案例-记录本(tomcat+mysql)
启动一个简单的集群: tomcat+mysql myweb-pod.yaml apiVersion: v1 kind: Pod metadata: name: myweb labels: app: m ...
- [svc]打通mysql主从同步
MySQL数据库设置主从同步 主从同步的特点: 逻辑的 异步的 主从同步的作用 1.备份 2.读写分离 主从同步的步骤 准备环境 1, mysql版本一致 5.5以上 2, 主从数据库一致 主库mas ...
- RxSwift之路 2#如何开始
RxSwift之路 2#如何开始 第一步当然是把项目clone到本地,github地址:https://github.com/ReactiveX/RxSwift. 官方文档 学习的第一手资源当然是项目 ...
- jsonp的工作原理
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Selenium Web 自动化 - 项目实战环境准备
Selenium Web 自动化 - 项目实战环境准备 2016-08-29 目录 1 部署TestNG 1.1 安装TestNG 1.2 添加TestNG类库2 部署Maven 2.1 mav ...
- [转]Ubuntu 16.04安装有道词典
原文:https://www.cnblogs.com/scplee/archive/2016/05/13/5489024.html 以前用Ubuntu 14.04 的时候,直接下载有道词典官方deb安 ...
- LeetCode: Find Peak Element 解题报告
Find Peak Element A peak element is an element that is greater than its neighbors. Given an input ar ...
- 小矮人Javascript模块加载器
https://github.com/miniflycn/webkit-dwarf 短小精悍的webkit浏览器Javascript模块加载器 Why 我们有许多仅基于webkit浏览器开发的应用 无 ...
- var_dump
1:var_dump 主要输出类型和.长度和变量的值: 2: var_dump() 能打印出类型print_r() 只能打出值echo() 是正常输出...需要精确调试的时候用 var_dump(); ...