Git Product home page Git Product logo

Comments (4)

Jaxartes avatar Jaxartes commented on August 11, 2024 1

Confirmed in testing that with commit 005c504, the result of "PRINT 1000*(.7-LOG(2))" changed from 6.85281931 (as on C64) to 6.85281919 (as now).

from x16-rom.

MJoergen avatar MJoergen commented on August 11, 2024

Interesting. I did change the ADD, MULT, and SQR routines in the math library to more optimized versions (see commit 005c504) two years ago. It could be worth looking into, whether this change is the source of the error.

I don't have the opportunity to test this myself at the moment, so this is just informational, in case someone else picks up from here.

from x16-rom.

Jaxartes avatar Jaxartes commented on August 11, 2024

Strangely, it appears 'fmult' is more accurate than before commit 005c504 (at least in one relevant case) but something in 'log' that didn't change was wrong. Or else there's something strange about how 'facov' (the overflow/rounding byte) is handled.

In both the current code and before 005c504, LOG(2) ends with multiplying 'log2' by the following value in 'fac': 81 80 00 00 00 80 (where the last byte I've listed is that in 'facov' though it's not contiguous in memory). The result given for that is different, 80 B1 72 17 F8 2C with the old code and 80 B1 72 17 F8 B0 with the new.

Assuming 'facov' is a straightforward 8 bit extension of the mantissa of FAC then the new result is more accurate. Is that assumption right? I don't know.

Data:
80 31 72 17 f8 .. = 0.6931471806019545 (log2 in memory)
81 80 00 00 00 80 = 1.0000000002328306 (fac passed to fmult)
80 B1 72 17 F8 2C = 0.6931471806419722 (old code, better LOG(2))
80 B1 72 17 F8 B0 = 0.6931471807620255 (new code, better product)

from x16-rom.

MJoergen avatar MJoergen commented on August 11, 2024

I seem to remember that 'facov' indeed is just the eight following bits of the accumulator, used for extra accuracy. Or maybe 'facov' really only contains one or two bits (rather than eight), I'm not sure.

Now, the line "fac passed to fmult" should contain the exact real value 1.0, since this should be the log base 2 of the input value. I believe the value shown is the result of a lenghty calculation, so presumably there is some accumulated rounding error in this preceding calculation.

from x16-rom.

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.