[SOLVED] issue with modulo function in expressions

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
MIngB
Posts: 26
Joined: Sat Jan 28, 2017 5:01 pm

[SOLVED] issue with modulo function in expressions

Postby MIngB » Sun Jul 16, 2017 7:30 am

it seems that the modulo operator doesn't return the correct dimension.
Actually I think mod(x;y) should do the same as 'x/y-floor(y/y)'
While mod(7mm;3) returns correct 1mm, mod(7mm/3mm) throws an error instead of the correct result 1

I added a FreeCAD Spreadsheet which documents the mod results against the 'x/y-floor(y/y)' results.
ModuloExpr.fcstd
(1.46 KiB) Downloaded 14 times
ModuloExpr.png
ModuloExpr.png (40.43 KiB) Viewed 638 times
OS: "NAME=Gentoo"
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.17.11586 (Git)
Build type: Debug
Branch: (HEAD detached at e6b9ec5db)
Hash: e6b9ec5dbcb57db186653d5cd22450418c454439
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 7.1.0
Last edited by MIngB on Sat Aug 05, 2017 4:48 am, edited 1 time in total.
wmayer
Site Admin
Posts: 16465
Joined: Thu Feb 19, 2009 10:32 am

Re: issue with modulo function in expressions

Postby wmayer » Sun Jul 16, 2017 8:14 am

User avatar
Kunda1
Posts: 8455
Joined: Thu Jan 05, 2017 9:03 pm

Re: issue with modulo function in expressions

Postby Kunda1 » Tue Jul 18, 2017 11:30 am

PR 884 submitted by @eivindkvedalen
That was quick! Thanks!
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 8455
Joined: Thu Jan 05, 2017 9:03 pm

Re: issue with modulo function in expressions

Postby Kunda1 » Fri Jul 21, 2017 11:14 am

MIngB wrote:
Sun Jul 16, 2017 7:30 am
...
@MIngB can you test, confirm and prepend [Solved] to this thread ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features