Hacker News new | past | comments | ask | show | jobs | submit login

Well, huh. "bc" is still that bad:

  % bc -l
  bc 1.06
  Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
  This is free software with ABSOLUTELY NO WARRANTY.
  For details type `warranty'.
  (824633702441.0)*(1/824633702441.0)
  .99999999224129613242
  (824633702441.0)*(1/824633702441.0)-0.999999996274709702
  -.00000000403341356958
  ((824633702441.0)*(1/824633702441.0))/0.999999996274709702
  .99999999596658641539
Python on the same machine is not:

  % python
  Python 2.7.10 (default, May 26 2015, 13:01:57)
  [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> (824633702441.0)*(1/824633702441.0)
  0.9999999999999999



In bc, write

    scale=1000
(or however many digits you want) first, and you'll get better results.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: