M
my.correo.basura
Yesterday I found in a piece of code a float being incremented with ++.
For some reason (wrong, I guess...) I thought that only integer types
could be incremented that way, and I had never seen floats or doubles
incremented that way before. Just to be sure I did a toy program and
compiled with gcc -ansi -pedantic -Wall and it worked without any error
or warning, showing the correct result.
Is it correct to increment floats or doubles with ++ and --? Is it
defined or am I getting into the realm of undefined behaviour? If it's
correct, can you think of a place where it could be useful?
Many thanks for your time,
Al
For some reason (wrong, I guess...) I thought that only integer types
could be incremented that way, and I had never seen floats or doubles
incremented that way before. Just to be sure I did a toy program and
compiled with gcc -ansi -pedantic -Wall and it worked without any error
or warning, showing the correct result.
Is it correct to increment floats or doubles with ++ and --? Is it
defined or am I getting into the realm of undefined behaviour? If it's
correct, can you think of a place where it could be useful?
Many thanks for your time,
Al