Giter VIP home page Giter VIP logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
Fix for the general 64bit cases:

Index: fix16.c
===================================================================
--- fix16.c (revision 51)
+++ fix16.c (working copy)
@@ -35,7 +35,7 @@
    #ifndef FIXMATH_NO_64BIT
    int64_t tempResult = ((int64_t)inArg0 * (int64_t)inArg1);
    #ifndef FIXMATH_NO_ROUNDING
-   tempResult += (fix16_one >> 1);
+   tempResult += (tempResult > 0) ? (fix16_one >> 1) : -(fix16_one >> 1);
    #endif
    tempResult >>= 16;
    return tempResult;
@@ -97,7 +97,7 @@
    int64_t tempResult = inArg0;
    tempResult <<= 16;
    #ifndef FIXMATH_NO_ROUNDING
-   tempResult += (inArg1 >> 1);
+   tempResult += (tempResult > 0) ? (inArg1 >> 1) : -(inArg1 >> 1);
    #endif
    tempResult /= inArg1;
    return tempResult;

Original comment by Petteri.Aimonen on 29 Nov 2011 at 8:24

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
Actually, for it to work also for result = 0:

Index: fix16.c
===================================================================
--- fix16.c (revision 51)
+++ fix16.c (working copy)
@@ -35,7 +35,7 @@
    #ifndef FIXMATH_NO_64BIT
    int64_t tempResult = ((int64_t)inArg0 * (int64_t)inArg1);
    #ifndef FIXMATH_NO_ROUNDING
-   tempResult += (fix16_one >> 1);
+   tempResult += (tempResult >= 0) ? (fix16_one >> 1) : -(fix16_one >> 1);
    #endif
    tempResult >>= 16;
    return tempResult;
@@ -97,7 +97,7 @@
    int64_t tempResult = inArg0;
    tempResult <<= 16;
    #ifndef FIXMATH_NO_ROUNDING
-   tempResult += (inArg1 >> 1);
+   tempResult += (tempResult >= 0) ? (inArg1 >> 1) : -(inArg1 >> 1);
    #endif
    tempResult /= inArg1;
    return tempResult;

Looks like we could use some validation framework :)

Original comment by Petteri.Aimonen on 29 Nov 2011 at 8:36

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
Agreed, we have some tests but they clearly aren't even close to exhaustive. 
Would you be interested in joining the project? There are no expectations of 
work but it means you can make any reasonable changes you'd like to improve the 
codebase.

Original comment by [email protected] on 30 Nov 2011 at 10:02

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
I'm currently working on a fix16_t based matrix algebra library, so yes, I 
would be interested.

Original comment by Petteri.Aimonen on 30 Nov 2011 at 10:17

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
This issue was closed by revision r52.

Original comment by Petteri.Aimonen on 26 Jan 2012 at 3:43

  • Changed state: Fixed

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.