c – What does 1e mean?

c – What does 1e mean?

In C, 1e6 has type double and its value is 1 times 10 raised to the 6th power. It is equivalent to 1000000.0.

Do not get fooled by the other answers: 1e6 does not mean the same thing as 1000000 in C, because 1e6 has type double while 1000000 will have some integer type. There are big differences in behavior between floating-point types like double and integers types.

The syntax for writing numbers like 1e6 is defined in the Floating constants section of the C11 specification (and earlier versions too). Its kind of like scientific notation.

That is 1e6, not le6, and it means 1 * 10^6 or 1000000.0

It is scientific notation.

c – What does 1e mean?

Ive seen some code online and Im trying to work out what it is
doing. In particular, Ive never seen 1e convention before.

As others have mentioned, practically speaking, 1e6 is scientific notation for 10^6 which is 1000000 or better known as 1 million. But as has already been mentioned, by David, this is actually treated as a double in C and the value is actually 1000000.0.

But I feel like these answers only focus on that specific piece of the code you provided and not the whole so I wanted to provide some additional context for you since you are trying to work out what the code is doing.

For these lines:

time_t currentTime;
time(&currentTime);

time takes a pointer time_t and operates on it, presumably writing some semblance of time to it.

The next line is actually illegal because currentTime was already declared so lets make a small modification:

uint64_t convertedTime = (uint64_t)currentTime * 1e6;

This line converts time_t currentTime to an unsigned 64-bit integer then multiplies it by 1e6 or 1000000.0. This is likely being done for unit conversion. For instance, lets assume time wrote the time in microseconds (1e-6, 10^-6, or .000001) to currentTime so multiplying it by 1e6 will give you seconds. And I say that just because of what appears to be a unit conversion here not because I actually know what time did (i.e. Im taking the code at face value here).

Leave a Reply

Your email address will not be published.