Skip to content

Commit

Permalink
Document aliases 𝟎 and 𝟏.
Browse files Browse the repository at this point in the history
  • Loading branch information
perrutquist committed Aug 17, 2021
1 parent b4d7ef7 commit 166c14d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Zeros.jl

[![Build Status](https://travis-ci.org/perrutquist/Zeros.jl.svg?branch=master)](https://travis-ci.org/perrutquist/Zeros.jl)
[![Build Status](https://travis-ci.com/perrutquist/Zeros.jl.svg?branch=master)](https://travis-ci.com/perrutquist/Zeros.jl)
[![codecov.io](http://codecov.io/github/perrutquist/Zeros.jl/coverage.svg?branch=master)](http://codecov.io/github/perrutquist/Zeros.jl?branch=master)

This module provides singular datatypes named Zero and One. All instances of each datatype are identical, and represent the values zero and one, respectively. This is a light-weight alternative to [StaticNumbers.jl](https://github.com/perrutquist/StaticNumbers.jl) when only these two values are needed.
Expand All @@ -9,6 +9,8 @@ This module provides singular datatypes named Zero and One. All instances of eac

Since the value of a `Zero` or `One` is known at compile-time, the complier might be able to make optimisations that might not be possible otherwise.

With Julia v1.3 and later, the Unicode symbols `𝟎` and `𝟏` can be used as aliases for `Zero()` and `One()`. These can be entered from the keyboard as `\bfzero` or `\bfone` followed by a tab. (User beware: Depending on the font used, it might be hard to tell the difference between these symbols and the numbers `0` and `1`.)

Trying to convert a nonzero value to `Zero` will throw an `InexactError`.

Attempting to divide by `Zero()` will throw a `DivideError` rather than returning `Inf` or `NaN`.
Expand All @@ -20,5 +22,5 @@ The command
```
Zeros.@pirate Base
```
can be used to enable a few more method definitions, such as `+()` (the sum of zero terms)
can be used to enable a few more (rarely needed) method definitions, such as `+()` (the sum of zero terms)
and `*()` (the product of zero factors).

0 comments on commit 166c14d

Please sign in to comment.