Is there a way to round up/down/off floating point numbers into an integer or some specific level of precision within G code? E.g. #1 = [ceil[0.875 / 0.25]]
I ultimately want to control a loop and while I could manage with an iterator and conditional check, it would be much simpler and more useful everywhere to do the math in advance. I'm using v4.34, btw.
Math Round / Ceiling / Floor
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Math Round / Ceiling / Floor
Hi suumas,
FUP, FIX, and ROUND are supported
FUP, FIX, and ROUND are supported
Code: Select all
#1 = FUP[1.02] (ceil result 2)
#2 = FIX[1.02] (floor result 1)
#3 = ROUND[1.5] (round up/down result 2)
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Math Round / Ceiling / Floor
Thanks for the prompt reply!!
I'm searching through the help but I can't find those functions. Where can I find a complete list of all such functions?
I'm searching through the help but I can't find those functions. Where can I find a complete list of all such functions?
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Math Round / Ceiling / Floor
Hi suumas,
The GCode Interpreter is based on the public domain NIST RS274NGC Interpreter you can download a manual here. Section 3.3.2.3 describes expressions.
Or you can look at the source code See execute_unary() in \GCodeInterpreter\rs274ngc.cpp also add your own.
The GCode Interpreter is based on the public domain NIST RS274NGC Interpreter you can download a manual here. Section 3.3.2.3 describes expressions.
Or you can look at the source code See execute_unary() in \GCodeInterpreter\rs274ngc.cpp also add your own.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Math Round / Ceiling / Floor
Thanks again for a quick and complete answer!