Op zaterdag 7 juli 2018 14:50:46 CEST schreef Carlos E. R.:
Hi,
Do we have something that would round a number in a script?
I have:
case "$1" in 72.009|72) DPI=72 ;; 86.0044|86) DPI=86 ;; 96.01) DPI=96 ;; 240.005|240) DPI=240 ;; 149.99) DPI=150 ;; 265.99|266) DPI=266 ;; 299.999|300) DPI=300 ;; 265.989|266) DPI=266 ;; 359.99|359.994|360) DPI=360 ;; 359.99000000000000909) DPI=360 ;;
This is absurd. Now I have another value, 265.99000000000000909 and I have to add another exception. I think I can write up my own tool, but perhaps it already exists :-?
-- Cheers
Carlos E. R. (from 42.2 x86_64 "Malachite" at Telcontar) https://bits.mdminhazulhaque.io/linux/round-number-in-bash-script.html
In the past I used printf "%.0f\n" $NUMBER a lot in scripts -- Gertjan Lettink a.k.a. Knurpht openSUSE Board Member openSUSE Forums Team -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org