开发者

How to convert a floating point value in exponential form to dot notation? [duplicate]

This question already has answers he开发者_运维问答re: Closed 12 years ago.

Possible Duplicate:

Prevent scientific notation in ostream when using << with double

I get 1e-1 as result after a computation how can I convert the result from exponent to dot notation i.e., 0.1 ? Why is it automatically converted to exponential notation!!


You can use the fixed I/O manipulator to force the number to be printed in fixed-point notation:

double d = 42.0;
std::cout << std::fixed << d;

(std::scientific does the opposite: it forces the number to be printed in scientific notation)


Oracle (generally) doesn't do binary numbers (some support was added in 10g). Numbers are held in an internal format and, unless you use an implicit or explicit TO_CHAR, it is up to the "client" to display them (or any desired "prettifying").

select to_number('1e-1') num, 
       to_char(to_number('1e-1'),'9.9EEEE') sci_num, 
       to_char(to_number('1e-1')) std_num 
from dual;

            NUM SCI_NUM   ST
--------------- --------- --
            .10   1.0E-01 .1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜