I will get value like 2743410360.320 and I want value like 2743410360 to a variable.
INTValueOfGB=$ echo "($gb+0.5)/1" | bc
But I am getting
(standard_in) 1: syntax error
Your command needs a couple of
But that will not round the number, for that to work you need to set scale to 0:
That will round up (from x.5) to the next integer.
To get "round to next even integer" (Banker's rule), you need to use printf rounding:
The LC_NUMERIC is to ensure that numbers are processed with a dot as decimal.
That is not what users in Germany will like to use, this should work with decimals with
I don't see an answer to @vin's problem, which is:
In the comments to the @dchirikov's answer, @vin says
In both of the areas where @vin has problems, the unset variable reproduces the problem, and setting the variable solves the problem.