I need to round a number .. there is no function in reference to do that.
I have no idea how to do it.
It will be nice if there was a library that I could include to add some more math functions.
Maybe like these: abs, floor, int, mround (returns a number rounded to a specified multiple), roundup, rounddown, trunc
I guess abs helps to get to a rounded value. Sorry, I missed that.
Need to round down if <0.5 and up if >= 0.5. Pretty simple. Don’t really care if its <= and then >.
math.h sure does it ! Don’t know how I didn’t see that library. Will pay more attention next time.
I saw that library referenced once, but not linked to. It would be nice if that page had a clear download link.
Or if it were in the Libraries section of the Arduino playground, under "math" that would be good too.
aefields:
It would be nice if that page had a clear download link.
The Arduino environment is essentially a set of training wheels built around the more generic AVR-GCC and AVR-LIBC projects. When you compile a sketch, these core tools are used to compile and link. Pretty well everything documented in the AVR-LIBC documentation (www.nongnu.org/avr-libc/) is directly usable in Arduino and works as advertised there. You will find numerous links in these forums back to the AVR-LIBC documentation.
Despite the fact that the AVR-LIBC documentation is referenced on the Arduino References page, it is one of my pet peeves that it is not more prominently referenced, or more completely re-documented in the Arduino docs. If you look, you'll see: "Looking for something else? .... The Arduino language is based on C/C++. It links against AVR Libc and allows the use of any of its functions; see its user manual for details."
It would be nice if that page had a clear download link.
For math.h? You already have math.h. You don't need to download it.
Oh! I saw a sketch which had an include statement for math.h and that misled me. I thought it was an Arduino library and had to be in the "libraries" folder. Thanks for clarifying.