bash and bc: Rounding numbers?
How would I get bc to return a round number here?
z=$(echo "scale=10; 352/$x*$y" | bc -l)
Either rounded up or down to the nearest integer, I don't care. I've read the man page and can't see any way to round things.
EDIT: Right now I'm doing it this way:
#!/bin/bash
x=624
y=352
z=$(echo "scale=10; 352/$x*$y" | bc -l)
l=$(echo "scale=10; length(352/$x*$y)-10" | bc -l)
z=${z: 0:$l}
echo $z
:But there has to be a saner way?
z=$(echo "scale=10; 352/$x*$y" | bc -l)
Either rounded up or down to the nearest integer, I don't care. I've read the man page and can't see any way to round things.
EDIT: Right now I'm doing it this way:
#!/bin/bash
x=624
y=352
z=$(echo "scale=10; 352/$x*$y" | bc -l)
l=$(echo "scale=10; length(352/$x*$y)-10" | bc -l)
z=${z: 0:$l}
echo $z
:But there has to be a saner way?
