Anton Aylward wrote:
On 07/07/18 08:50 AM, Carlos E. R. wrote:
Do we have something that would round a number in a script?
In a Ruby script there is the numeric function 'floor()' that does all of what you describe. I see that it is also available in the POSIX compatibility module for Perl. There is a similar function in Python.
The bash shell doesn't, it seems, do floating point arithmetic. of course the older ksh does
---
for i in 72.0009 86.0044 96.01 240.005 do ksh93 -c "print $(( floor($i) ))" done
----
OOPS! have to start that in ksh93 anyway as bash upchuks on things like "72.0009".
It works fine here: for i in 72.0009 86.0044 96.01 240.005 do printf "%.0f\n" $i done 72 86 96 240 -- Per Jessen, Zürich (25.7°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org