Friday, 15 August 2014

bash - How can I get float division? -



bash - How can I get float division? -

i trying split 2 image widths in bash script, bash gives me 0 result:

result=$(($img_width/$img2_width))

i did study bash guide , know should utilize bc, in examples in net utilize bc. in echo tried set same thing in scale didn't work.

here illustration found in tutorials:

echo "scale=2; ${userinput}" | bc

how can bash give me float 0.5?

you can't. bash only integers; must delegate tool such bc.

bash floating-point

No comments:

Post a Comment