[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 ...
随机推荐
- fork failed because of Out Of Memory
Maybe virtual memory over commit is prevented in your system. If it is prevented, then the virtual m ...
- <转>vmp3.0.9全保护拆分解析
以下为了避免插件干扰,故采用x64dbg原版进行分析. 首先我通过检测到调试器的弹窗进行栈回溯,定位到该关键点:CALL eax 由于才接触Vmp,所以是把各个保护拆分开来进行的分析,会比较简单一 ...
- C#去除HTML标签
public static string ReplaceHtmlTag(string html, int length = 0) { string strText = System.Text.Regu ...
- 11G新特性 -- flashback data archive(1)
虽然可以依赖undo数据来查询row的旧版本数据,甚至可以执行逻辑恢复.但是你不能期待在undo中找到非常旧的数据.undo数据主要是用来提供读一致性. 在11G中,提供了Flashback Data ...
- jsoup 是一款Java 的HTML解析器,可直接解析某个URL地址
jsoup 是一款Java 的HTML解析器,可直接解析某个URL地址.HTML文本内容.它提供了一套非常省力的API,可通过DOM,CSS以及类似于jQuery的操作方法来取出和操作数据.
- 浅析Mysql的my.ini文件
转载:http://hunanpengdake.iteye.com/admin/blogs/1647725 今天闲的蛋疼,没事想了解mysql,大家都知道在配置Mysql的过程中,my.ini非常重要 ...
- jsonp的工作原理
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- [C++]Qt文本操作(按行读写)
资料来源:https://blog.csdn.net/flyfish1986/article/details/79487104 #include <QDebug> #include < ...
- 基于CSS3动态背景登录框代码
基于CSS3动态背景登录框代码.这是一款基于jQuery+CSS3实现的带有动画效果的动态背景登陆框特效.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class ...
- golang 命令行cobra妙用
为什么使用命令行 大型项目中少不了数据升级,如果采用web服务,一来不够安全,二来数据量大的时候也会出超时的情况.这时使用命令行是比较合适的方式了. 命令行中的MVC web项目一般采用MVC模式,对 ...