I have two numbers:
value1=686
value2=228.35
I am not able to add an integer and a float. Please help me out to get the result.
I am running it in bash.
I have two numbers:
value1=686
value2=228.35
I am not able to add an integer and a float. Please help me out to get the result.
I am running it in bash.
Just replace the numbers with your variables, eg:
echo $n1 + $n2 | bc
Bash doesn't have floating-point types, but you can use a calculator such as
bc
:If you have the
bc
language installed, you can do the following:If you don't have
bc
, then you can try with awk. Just in one single line:There are plenty of other options, also. Like python, perl, php....