Connecting Tech Pros Worldwide Forums | Help | Site Map

How to represent the scientific notation?

asdf
Guest
 
Posts: n/a
#1: Oct 21 '06
For example, I have a number which is 1.2*10^(-12), how can I write it
in C++?
"double i=1.2*10^(-12)" is an error.

Thanks for your reply.


Peter Jansson
Guest
 
Posts: n/a
#2: Oct 21 '06

re: How to represent the scientific notation?


asdf wrote:
Quote:
For example, I have a number which is 1.2*10^(-12), how can I write it
in C++?
"double i=1.2*10^(-12)" is an error.
>
Thanks for your reply.
>
double i(1.2E-12);


Sincerely,

Peter Jansson
http://www.p-jansson.com/
http://www.jansson.net/
Rolf Magnus
Guest
 
Posts: n/a
#3: Oct 21 '06

re: How to represent the scientific notation?


asdf wrote:
Quote:
For example, I have a number which is 1.2*10^(-12), how can I write it
in C++?
"double i=1.2*10^(-12)" is an error.
That's because '^' is the exclusive or operator. Try:

double i = 1.2e-12;

Closed Thread