Skip to main content
added 83 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k

The bc utility does not understand 6.65E+07 as the number you want it to be. The

On OpenBSD, the E here is hexadecimal, so 6.65E is 6.664 (6.65 + 0.014), and then +07 will add 7 to that, yielding 13.664, and that is clearly less than 50.960. On GNU systems, 6.65E is 6.659 which is also not what you want.

Instead, you want num2 to be the string 6.65*10^7 or 66500000.

$ num1=50.960; num2='6.65*10^7'; printf '%s < %s\n' "$num1" "$num2" | bc 1 

The bc utility does not understand 6.65E+07 as the number you want it to be. The E here is hexadecimal, so 6.65E is 6.664 (6.65 + 0.014), and then +07 will add 7 to that, yielding 13.664, and that is clearly less than 50.960.

Instead, you want num2 to be the string 6.65*10^7 or 66500000.

$ num1=50.960; num2='6.65*10^7'; printf '%s < %s\n' "$num1" "$num2" | bc 1 

The bc utility does not understand 6.65E+07 as the number you want it to be.

On OpenBSD, the E here is hexadecimal, so 6.65E is 6.664 (6.65 + 0.014), and then +07 will add 7 to that, yielding 13.664, and that is clearly less than 50.960. On GNU systems, 6.65E is 6.659 which is also not what you want.

Instead, you want num2 to be the string 6.65*10^7 or 66500000.

$ num1=50.960; num2='6.65*10^7'; printf '%s < %s\n' "$num1" "$num2" | bc 1 
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k

The bc utility does not understand 6.65E+07 as the number you want it to be. The E here is hexadecimal, so 6.65E is 6.664 (6.65 + 0.014), and then +07 will add 7 to that, yielding 13.664, and that is clearly less than 50.960.

Instead, you want num2 to be the string 6.65*10^7 or 66500000.

$ num1=50.960; num2='6.65*10^7'; printf '%s < %s\n' "$num1" "$num2" | bc 1