skzlzl / libfixmath

Automatically exported from code.google.com/p/libfixmath
0 stars 0 forks source link

Const fix to/from float/double #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Idea by Joe Schaack quoted from his post to the mailing list:

I was wondering if implementing a const_fix16_from_float() define would be 
worth it, so that we could keep the code easy to read.
       const_fix16_from_dbl(24.3323) is much easier to understand versus the decimal number 1594641.
       Something like.
       #define const_fix16_from_dbl(x) ((fix16_t)(x*65536.0))
       This should get solved at compile time.

Original issue reported on code.google.com by Flatmush@googlemail.com on 24 Feb 2011 at 1:59

GoogleCodeExporter commented 9 years ago
I think we could replace all the fix16_to_xxx and fix16_from_xxx with #defines.
This way we let the compiler choose what to do.  If a user decides to pass a 
variable into the fix16_from_dbl() the compiler will have to keep the 
conversion in the compiled program.  If the user passes a number in the 
compiler will optimize it away.

Original comment by joe.scha...@gmail.com on 24 Feb 2011 at 8:04

GoogleCodeExporter commented 9 years ago
Just done it, the same minute you posted on the issue (what are the chances of 
that) :)

Original comment by Flatmush@googlemail.com on 24 Feb 2011 at 8:06

GoogleCodeExporter commented 9 years ago

Original comment by Flatmush@googlemail.com on 24 Feb 2011 at 8:07