9 years, 8 months ago.

why wait(0.2f) and not wait(0.2)?

Sorry,

but I can't understand why in the Programm is wait(0.2f) and not wait(0.2).

What this "f" is doing?

When I'm delete it, I can't see a difference.

If the "f" in wait(0.2f) would be a mistake, the compiler would tell me it, but he didn't.

Thank you!

Question relating to:

gpio example for the Freescale freedom platform Freedom, Freescale, GPIO

1 Answer

9 years, 8 months ago.

Depending on the compiler, 0.2 may be stored as either a 32-bit float or a 64-bit double. The "f" forces it to be stored as a float. This is important on slow platforms (like mbed) because doubles are substantially slower to deal with, so if you're not sure how the compiler is configured you can force it to store your constant as a float. The mbed compiler appears to store constants has floats though, so deleting it won't make a difference.

Accepted Answer