GithubHelp home page GithubHelp logo

Comments (4)

MikeLankamp avatar MikeLankamp commented on July 18, 2024

Hi @Klummel69, this is not possible at the moment, but it makes sense to be able to do that.

However, the point of fpm is to be explicit about conversions that potentially throw away information so this functionality should be added as an explicit constructor so you can write:

fixed2 = fpm::fixed_16_16(fixed1);

from fpm.

Klummel69 avatar Klummel69 commented on July 18, 2024

Great, thanks for adding the feature. This increases the quality of the library.

I plan to store data types with different solutions.

  • Angles: 8_24 format (-2 π … 2 π)
  • Coordinates: 16_16 or 24_8 format.

This keeps angle calculations more accurate. Only after trigonometric calculations the resolution is reduced.

Example:

    fpm::fixed_8_24 w {1.047197551};
    fpm::fixed_16_16 x,y;
    //w = w1+w2+w3;
    x = 100 * fpm::fixed_16_16(fpm::sin(w));
    y = 100 * fpm::fixed_16_16(fpm::cos(w));

A possibility of conversion without explicit construction would be good, but it is bearable.

from fpm.

MikeLankamp avatar MikeLankamp commented on July 18, 2024

A possibility of conversion without explicit construction would be good.

I understand the desire to have this, but it's generally a bad idea. The C++ Core Guidelines also discourage this: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es46-avoid-lossy-narrowing-truncating-arithmetic-conversions

Hence the decision to have these kind of conversions explicit.

from fpm.

Klummel69 avatar Klummel69 commented on July 18, 2024

You got me. Actually, I try to follow the guideline. I had used template code that was not compliant with the guideline. In the meantime I have corrected that. Thanks.

from fpm.

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.