Monday, 5 October 2020

Shell calculate float without bc(coomand line calculator)

 2

Why do you even need bc on a GIT bash?

A typical usage would be:

Prompt>echo $(1+2 | bc) // or something similar

Recently I've found out that double brackets do the thing, even without bc:

Prompt>$ echo $((1+2))
Prompt>3

Edit after first comment

In case you need floating point calculations, you might use awk, as in this example:

Prompt>awk 'BEGIN {print (20.0+5)/7}'
Prompt>3.57143

https://stackoverflow.com/questions/55141267/how-to-install-and-where-to-install-bash-bc-on-windows

No comments:

Post a Comment