Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of %lf and %le

Status
Not open for further replies.

WebDrake

Programmer
Sep 29, 2005
106
PL
Hello all,

A bit of a dumb question here but I'll ask anyway.

What is the difference between %f and %e, and their counterparts %lf and %le?

I note that if used in printf it makes no difference, at least with the compiler I am using---the same on-screen precision is given.

However, I seem to recall code not compiling when anything but %le was used in a scanf function.

Can someone explain? :)

Best wishes,

-- Joe
 
You MUST make a differences between long (with l prefix) and ordinal floating point format specifiers in scanf(). Long forms must correspond with double and ordinal - with float arguments. You may have serious troubles if (most of) the target computer has different double and float internal (binary) representation. The scanf (and printf) family functions do not know its arguments real types (remember prototype int scanf(const char*,...);).
 
Aaahhh, that makes sense. Thanks very much. :)

I've always used %le for scanning doubles, but couldn't bring to mind why... :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top