I'm not understanding something

K

Keith Thompson

Jordan Abel said:
It produces undefined behavior. For example, it would be reasonable for
a pure c89 printf implementation to use the same internal flag for l and
L.

C90 specifically says that "%lf" invokes undefined behavior.

C99 says that the 'l' in "%lf" has no effect.

IMHO this is similar to the C99 rule that falling off the end of
main() is equivalent to executing "return 0;"; it causes some
previously undefined code to become defined, but is not helpful for
code that was correct in the first place.

There is no good reason to use "%lf" rather than "%f".
 
P

pete

Keith Thompson wrote:
C99 says that the 'l' in "%lf" has no effect.

IMHO this is similar to the C99 rule that falling off the end of
main() is equivalent to executing "return 0;"; it causes some
previously undefined code to become defined, but is not helpful for
code that was correct in the first place.

Those were my two counter examples to Doug Gwyn's claim
that the standard doesn't cater to sloppy programmers.
 
R

Rod Pemberton

RadiationX said:
This is the problem that I have to solve :
The
conversion formulas are as follows, where C is a temperature in degrees
Celsius, and F the equivalent in Fahrenheit:

C = (5.0 / 9.0) * (F - 32)
F = ( (9.0 / 5.0) * C ) + 32

Using more symmetric equations might improve your coding:

C=((5/9)(F+40))-40
F=((9/5)(C+40))-40


Rod Pemberton
 
R

RadiationX

Thanks everyone who helped me out. I finally found my bugs and fixed
them.
I'm a very very novice programmer and some of the things that were
suggested to me I have not had any exposure to them so I could not
implement them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top