Re: [OT] bc und mathematisches problem
Hi Michele,
Michelle Konzack <linux4michelle@freenet.de> wrote:
>Ich mache es jetzt mit echo "3%2" |bc , also "modula".
Warum nicht gleich mit der bash? Wäre unter Umständen die schnellere
Lösung.
--- modulo_bash_only.sh -----------
#!/bin/bash
for ((i=1;i<2000;i++))
do
echo " % $i = $((20%$i))"
done
-----------------------------------
time ./modulo_bash_only.sh
real 0m0.119s
user 0m0.076s
sys 0m0.016s
--- modulo_with_bc.sh -------------
#!/bin/bash
for ((i=1;i<2000;i++))
do
echo "$i%42"|bc
done
-----------------------------------
time ./modulo_with_bc.sh
real 0m2.919s
user 0m0.964s
sys 0m1.960s
Frank
--
Reply to: