I have the following Bash code, which runs a C++ binary (./code
) and stores the result:
#!/bin/bash
output=$(./code /);
read -ra arr -d '' <<<"$output"
value=${arr[-1]}
sum=$value+1.034
echo $sum
I want it to be able to take the value of the variable sum
, which is a number less than zero, ie 0.01357
and be able to add another floating point number to it, before outputting the result to the screen.
So the result should be 1.04757, but the output I am currently getting is:
0.01357+1.034