Giter VIP home page Giter VIP logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 22, 2024
Hey, this isn't a bug. When you assign integers to a fixed, it's giving it the 
literal binary representation. It's not particularly pretty but C/C++ are 
pretty limited in this regard, there's no way to add in our own number parser 
to correctly parse a fixed point number and the only way to accurately 
initialize is an int.

I think there's an issue ticket somewhere to make this more clear. If you want 
to initialize a number as a float then you'll have to use the conversion 
functions.

The integer value 32767 is actually 0.5 in Q16.

Original comment by [email protected] on 8 Jan 2013 at 3:23

  • Changed state: Invalid

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 22, 2024
Thanks for the quick reply!

Original comment by [email protected] on 8 Jan 2013 at 3:29

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 22, 2024
Yeah, to clear things up for anyone else who might read this bug report later, 
you need to do it like this:

fix16_t value1 = fix16_from_int(123);
float value2 = fix16_to_float(value1);

For declaring constant values, you can also use shorthand macro F16(), like 
this:

fix16_t value3 = F16(1234.53); // Works for int, float, double arguments

Original comment by Petteri.Aimonen on 8 Jan 2013 at 3:33

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 22, 2024
I would also like to point out that the F16 macro is not part of the code thats 
in the downloads section as of 1/8/13 but it is in the latest commit of the 
repository.

Original comment by [email protected] on 8 Jan 2013 at 3:48

from libfixmath.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.