On 2018-07-07 15:19, Knurpht@openSUSE wrote:
Op zaterdag 7 juli 2018 14:50:46 CEST schreef Carlos E. R.:
https://bits.mdminhazulhaque.io/linux/round-number-in-bash-script.html
In the past I used printf "%.0f\n" $NUMBER a lot in scripts
Thanks. I tried: #!/bin/bash NUMBER=265.99000000000000909 printf "%.0f\n" $NUMBER but I get: cer@Telcontar:~> bash bin/float_test bin/float_test: line 3: printf: 265.99000000000000909: invalid number 0 cer@Telcontar:~> Mmm? maybe too many digits? The link you posted suggests: printf "%.0f\n" 123.456 But I get an error with that: cer@Telcontar:~> printf "%.0f\n" 123.456 bash: printf: 123.456: invalid number 0 cer@Telcontar:~> Ah, I know why: cer@Telcontar:~> printf "%.0f\n" 123,456 123 cer@Telcontar:~> The locale. Ugh. So... cer@Telcontar:~> LC_NUMERIC=en_GB.utf8 printf "%.0f\n" 123.456 123 cer@Telcontar:~> Thank you both :-) -- Cheers / Saludos, Carlos E. R. (from 42.3 x86_64 "Malachite" at Telcontar)