Machsupport Forum

Mach Discussion => Brains Development => Topic started by: rrc1962 on December 20, 2010, 05:57:14 PM

Title: Rounding number in brains formula
Post by: rrc1962 on December 20, 2010, 05:57:14 PM
Can you round a number in a formula.  I need to round the output of a formula to zer decimal places.  IE 4.8973 needs to equal 5.  The VB script function Round() doesn't work.

Thanks
Title: Re: Rounding number in brains formula
Post by: poppabear on December 22, 2010, 10:24:43 AM
you would need to do a work around.
send the dec val to a UDRO, then in macropump, read in that udro, do a vb round on it, repost it to another udro
in brains read in that rounded udro val and do what ever.

scott
Title: Re: Rounding number in brains formula
Post by: Program on March 12, 2016, 04:06:10 PM
Just in case someone else in the future is looking for another solution to this.

I managed to round a value in brains using a formula someone had posted at stackoverflow.
http://stackoverflow.com/a/17666483

The attached image is of an example rounding the spindle frequency in Hz.

I entered s500 in MDI in mach3, the formula I have then takes the spindle speed and divides by my motors RPM at 60Hz (1765), I then multiply by 60 to get the Hz number.