Search code examples
cmath

How to specify a negative power of base 10?


I would like to enter values like z = 5e-3 (that is, z = 0.005) and w = 5e6 into my code.

I've looked through documentation on the pow10 function, but of course something like double pow10(int -9); isn't allowed.

I'm using Code::Blocks 13.12 for C++ on Windows 7.

Any ideas?


Solution

  • double z = 5e-3;
    

    works, or alternatively

    double z = 5*pow(10, -3);
    

    (I presume you're using C, or C++. You didn't specify in the question or the tags; but the "cmath" tag was used.)