News for hackers. Stuff that matters.
Re:Fast midpoint between two integers without overflow by gumby on Wednesday December 07, 2022 @10:20AM (#33895336)
> If I ever create a programming language, one thing I'd like to try is to promote integer operations to larger types, so there is never overflow.

Are there any languages other than Lisp and Python that have automatic bignum support?

Re:Fast midpoint between two integers without overflow by fulafel on Wednesday December 07, 2022 @10:30AM (#33895472)
Pike, Haskell.

Clojure makes a gesture toward it, literals are automatically promoted but the normal operators don't do it:

  user=> (+ 1 9223372036854775807) ;; max signed int64
  Execution error (ArithmeticException) at user/eval5 (REPL:1).
  integer overflow
  user=> (+ 1 9223372036854775808) ;; one higher
9223372036854775809N
Re:Fast midpoint between two integers without overflow by eesmith on Wednesday December 07, 2022 @02:35PM (#33899098)
Tcl. In tclsh:

  % expr 1 + 9223372036854775807
  9223372036854775808
  % expr 9223372036854775808 + 1
  9223372036854775809
Re:Fast midpoint between two integers without overflow by ErikCorry on Wednesday December 07, 2022 @05:37PM (#33901364)
Dart initially had it, but JS compatibility was more important.

However they don't have JS compatibility either (Dart does not round off large integers like JS does), so I forget what the point was.

Dart also (very early) had infinite precision fractions. So if you divided 355 by 113 you didn't get 3 or 3.1415... you got the fraction 355/133 which was an instance of a first class numeric type.

Unfortunately this means your numbers can grow to need arbitrary amounts of storage in loops.

Re:Fast midpoint between two integers without overflow by gumby on Wednesday December 07, 2022 @06:28PM (#33901878)
Commonlisp has rationals as well (355/133) though division doesn't generate them by default.
Re:Fast midpoint between two integers without overflow by arh68 on Wednesday December 07, 2022 @10:46AM (#33895667)
Erlang's got them, I'm pretty sure.
Re:Fast midpoint between two integers without overflow by OkayPhysicist on Wednesday December 07, 2022 @04:03PM (#33900202)
Yep, integers on the BEAM are unbounded, since the language was built with "This program will run forever" as a design concern. Indices capping out and causing crashes was not an acceptable state of affairs.
Re:Fast midpoint between two integers without overflow by tudorpavel on Wednesday December 07, 2022 @10:35AM (#33895537)
Ruby's Integer type works like BigInteger under the hood.