cyrilcode / cyril

The Cyril programming language is designed for fast prototyping of visualisations and live coding visuals.
http://cyrilcode.com
Other
145 stars 21 forks source link

Crash due floating point exception #35

Open emanuelbuholzer opened 6 years ago

emanuelbuholzer commented 6 years ago

Using the modulo operator with a fraction 0 > n > 1 causes cyril to crash due a divide by zero exception.

Example: box 1, 1, 1%0.1

darrenmothersele commented 6 years ago

This should be caught here (Line 214):

https://github.com/cyrilcode/cyril/blob/master/src/Cyril/Ops/CyrilBinaryOp.h#L214

Does the divide by 0 check (Line 206) work?

emanuelbuholzer commented 6 years ago

The divide by 0 check works. The problem is that modulo for a fraction is not defined and causes a divide by zero exception. Therefore the check should be like this: if (v2 >= 0 && v2 < 1).