Giter Club home page Giter Club logo

Comments (6)

ISSOtm avatar ISSOtm commented on May 27, 2024

Oh god, here come the floating-point nightmares. Can you add a println FMOD(-5.0, 0.0) line, and re-run? (The location within the file doesn't matter. It will be printed as another diff, so no need to change anything else either.)

from rgbds.

orbea avatar orbea commented on May 27, 2024

As I stated I lack this hardware, but I asked the reporter if they can help test.

If not I can try to cross-compile it later...

from rgbds.

aaaaaa123456789 avatar aaaaaa123456789 commented on May 27, 2024

The issue here is that the result of those operations is, respectively, infinity and NaN. Those values don't convert to integers cleanly. Some CPUs do it one way, some do it another way. Converting infinity or NaN to an integer in C is definitely UB and not portable in the slightest.

from rgbds.

Rangi42 avatar Rangi42 commented on May 27, 2024

Since rgbasm just has fixed-point, I'd suggest converting Infinity to the maximum positive value, -Infinity to the maximum negative value, and NaN to 0 (same as how various other non-asm-time-computable expressions become 0).

from rgbds.

orbea avatar orbea commented on May 27, 2024

It might be possible to reproduce this on x86_64 using ubsan with clang ( 18.1.2).

FLAGS='-O0 -g -fno-omit-frame-pointer -fsanitize=undefined' && make Q= CXXFLAGS="$FLAGS" LDFLAGS="$FLAGS" CXX=clang++
math...
--- /dev/null	2024-03-23 23:47:52.120956538 -0700
+++ /tmp/tmp.0Tczm9DMP3	2024-03-30 19:17:50.224177174 -0700
@@ -0,0 +1,2 @@
+src/asm/fixpoint.cpp:28:18: runtime error: -inf is outside the range of representable values of type 'int'
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/asm/fixpoint.cpp:28:18 
math.err mismatch!

from rgbds.

aaaaaa123456789 avatar aaaaaa123456789 commented on May 27, 2024

Honestly, I'd suggest a simple if (!isfinite(value)) value = 0; fix for all floats before being converted back to fixed β€” there's simply no reasonable representation for infinity or NaN, so you might as well kill the problem in one go.

from rgbds.

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.