Skip to content

Commit

Permalink
Document division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Nov 11, 2023
1 parent 920b269 commit 5f0a4a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/gleam/float.gleam
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
//// Functions for working with floats.
////
//// ## Division by zero
////
//// Gleam runs on the Erlang virtual machine, which does not follow the IEEE
//// 754 standard for floating point arithmetic and does not have an `Infinity`
//// value. In Erlang division by zero results in a crash, however Gleam does
//// not have partial functions and operators in core so instead division by zero
//// returns zero, a behaviour taken from Pony, Coq, and Lean.
////
//// This may seem unexpected at first, but it is no less mathematically valid
//// than crashing or returning a special value. Division by zero is undefined
//// in mathematics.

import gleam/order.{type Order}

/// Attempts to parse a string as a `Float`, returning `Error(Nil)` if it was
Expand Down
12 changes: 12 additions & 0 deletions src/gleam/int.gleam
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
//// Functions for working with integers.
////
//// ## Division by zero
////
//// In Erlang division by zero results in a crash, however Gleam does not have
//// partial functions and operators in core so instead division by zero returns
//// zero, a behaviour taken from Pony, Coq, and Lean.
////
//// This may seem unexpected at first, but it is no less mathematically valid
//// than crashing or returning a special value. Division by zero is undefined
//// in mathematics.

import gleam/float
import gleam/order.{type Order}

Expand Down

0 comments on commit 5f0a4a0

Please sign in to comment.