On 07/07/2018 02:50 PM, Carlos E. R. wrote:
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 :-?
numfmt --round=nearest --format='%.0f' Have fun, Berny