Skip to main content
2 of 3
added 12 characters in body
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Presumably your awk works with floating point values, like GNU awk seems to do:

$ gawk 'BEGIN{ a = 11111111111111111111; print a, a/22; }'
11111111111111110656 505050505050505024

It can't store 11111111111111111111 accurately, and it can't store the remainder accurately either (11111111111111111111 / 22 is 505050505050505029.81...).

Your expr seems to have a wider numeric range. Mine doesn't (the one from GNU coreutils 8.26):

$ expr 11111111111111111111 / 22
expr: 11111111111111111111: Numerical result out of range

bc or Python can be used for arbitrarily large numbers.

ilkkachu
  • 147.9k
  • 16
  • 268
  • 441