如何转换为小数

fenglily 2006-11-06 01:41:10
4.849753E-01
5.690675E+00
这样写表示什么??

我有一个文本文件,里面都是象上面那样的数,我想把它转换为小数的形式 (不要带E的这种)
应如何转换
...全文
199 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhitaoyang 2006-11-06
  • 打赏
  • 举报
回复
看楼主要保留几位小数了,例如2位的话,可以这样变下
i:= (int(4.849753E-01*100+0.5))/100;
小呆之家 2006-11-06
  • 打赏
  • 举报
回复
Use StrToFloat to convert a string, S, to a floating-point value. S must consist of an optional sign (+ or -), a string of digits with an optional decimal point, and an optional mantissa. The mantissa consists of 'E' or 'e' followed by an optional sign (+ or -) and a whole number. Leading and trailing blanks are ignored.

自己仔细看看前面这段文字吧。呵~~,你就明白了。

The DecimalSeparator global variable or its TFormatSettings equivalent defines the character that is used as a decimal point. Thousand separators and currency symbols are not allowed in the string. If S doesn't contain a valid value, StrToFloat raises an EConvertError exception.

The first form of StrToFloat is not thread-safe, because it uses localization information contained in global variables. The second form of StrToFloat, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of StrToFloat, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings.

fenglily 2006-11-06
  • 打赏
  • 举报
回复
dinglinger
这样就可以了啊
但是对的 不太明白 给你分了啊
天涯倦客 2006-11-06
  • 打赏
  • 举报
回复
4.849753E-01 e表示科学记数法。。 (初中数学讲的好像)。。
小呆之家 2006-11-06
  • 打赏
  • 举报
回复
var
d:double;
begin
d:=strtofloat('4.849753E-01');
showmessage(floattostr(d));
end;

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧