## Math Round / Ceiling / Floor

Moderators: TomKerekes, dynomotion

suumas
Posts: 3
Joined: Sat Dec 05, 2020 4:51 pm

### Math Round / Ceiling / Floor

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.

TomKerekes
Posts: 1515
Joined: Mon Dec 04, 2017 1:49 am

### Re: Math Round / Ceiling / Floor

Hi suumas,

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.

suumas
Posts: 3
Joined: Sat Dec 05, 2020 4:51 pm

### 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?

TomKerekes
Posts: 1515
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.
Regards,

Tom Kerekes
Dynomotion, Inc.

suumas
Posts: 3
Joined: Sat Dec 05, 2020 4:51 pm

### Re: Math Round / Ceiling / Floor

Thanks again for a quick and complete answer!