简体   繁体   English

将科学计数法字符串中的数字转换为使用有限的类C库浮动

[英]Convert number in scientific notation string to float with limited C-like library

I'm writing a program in CAPL (which is based on C and minus some concepts) to convert a string containing a number displayed in scientific notation to a float (doesn't strictly need to be a float but I think its an appropriate type for this). 我正在用CAPL(基于C并减去一些概念)编写程序,以将包含以科学计数法显示的数字的字符串转换为浮点数(严格来说,它不一定是浮点数,但我认为它是合适的类型为了这)。 For example: 例如:

-7.68000000E-06 should be converted to -0.00000768 -7.68000000E-06应该转换为-0.00000768

I've done some looking around for this and atof() comes up a lot but this is not supported in CAPL so I cannot use that. 我做了一些环顾四周,这和atof()来了很多,但在此不CAPL支持,所以我不能使用。

A list of the other C concepts not supported in CAPL: CAPL不支持的其他C概念的列表:

CAPL到C-支持表

Update: Thanks everyone for the help. 更新:谢谢大家的帮助。 M. Spiller's answer proved to be the easiest solution. M. Spiller的答案被证明是最简单的解决方案。 I have accepted this answer. 我已经接受了这个答案。

在CAPL函数被调用atodbl具有相同签名为C的atof

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM