Hello
ennuient mais??
#/bin/bash
TOT=21765
let NUM=$TOT/1000
(( NUU=$TOT/1000))
echo "$TOT $NUM $NUU"
le resulta est 21
Merci d'avance
Hello
ennuient mais??
#/bin/bash
TOT=21765
let NUM=$TOT/1000
(( NUU=$TOT/1000))
echo "$TOT $NUM $NUU"
le resulta est 21
Merci d'avance
Bash use ONLY INTEGER numbers!
Read man bash!
TOT=21765 NUM=`echo $TOT / 1000 |bc -l` echo "$TOT $NUM"
But don't be fooled, $NUM is a string, not a floating point number
Yes. You can install 'bc' to do more math in scripts, for example:
R=$(echo 'scale=3;21765/1000' | bc -l) echo $R
One drawback: it has no rounding, only truncation, so you'd have to improvise with +0.5 or use printf.
In Javascript and many other languages, there is no difference.
Irrelevant. The topic of this conversation is Bash, not javascript nor "many other languages".
Your digression seems meant only to confuse the issue under discussion.
Also it?s wrong. Strings and numbers are distinct types in JS.
In article (Dans l'article) , zeneca
Voltaire.
Va donc voir sur fr.comp.sys.raspberry-pi
They are typed, but it's weak rather than strong, and has automatic promotion
str = "1.570795"; num = 1.570795; res = 2 * str; alert([typeof(str), typeof(num), res, typeof(res)]);
A. Dumas:
Or you can keep truncation, but set up one extra digit of precision...
How does that help?
echo 'scale=4;1/3*3' | bc -l
Have something to add? Share your thoughts — no account required.
Ask the community — no account required