-1

Trying to do

1*2^-2

tried code

echo "$((1 * (1/2**2)))" == 0
printf %.3f "$((1 * (1/2**2)))" == 0.000
also tried echo 1/2 | bc == 0

Problem seems that division operator is only not working maybe its a bug in cygwin Executing code in cygwin bash Help

Tathastu Pandya
  • 326
  • 1
  • 8

2 Answers2

1

If awk is available:

$ awk 'BEGIN { print 1 * (1/2**2), 1* (1/2^2) }'
0.25 0.25

$ awk 'BEGIN { printf "%.3f / %.3f", 1 * (1/2**2), 1* (1/2^2) }'
0.250 / 0.250
markp-fuso
  • 28,790
  • 4
  • 16
  • 36
0
 echo "scale = 2; 1 * 2^-2" | bc

Also bc -l option works as suggested in comment

Tathastu Pandya
  • 326
  • 1
  • 8