chiark / gitweb /
move big comment into zcoord.rs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Oct 2020 22:33:00 +0000 (23:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Oct 2020 22:33:00 +0000 (23:33 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/bigfloat.ts
zcoord/zcoord.rs

index 5acef33cadbf26a3fb374605be3645dd541078e3..66e733a1f0bce0e649eafbdfa961a9044f970faa 100644 (file)
@@ -4,68 +4,6 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-// This is a really really shonky BigFloat with only a handful of
-// operations available!
-
-
-// Representation, and model, ought to have these properties
-//     CBOR is binary and compact
-//  *  JSON is not lossy
-//  *  JSON is human-comprehensible
-//  *  JavaScript can compare efficiently
-//     JavaScript can do arithmetic efficiently
-//  *  Limb size is 48 for fast JS arithmetic
-//     Limb size is small for not being too full of padding
-//  *  Limb size is big so step algorithm rarely encounters limb boundaries
-//
-// Many of these are not compatible (in theory extending
-// the serde data model might help a bit, but not completely).
-// We choose those properties marked with "*".
-//
-// Main representation is a string:
-//   VVVVVVVVVV_VVVVVVVVVV ...]
-// where
-//   VVVVVVVVVV = 50 bits in lowercase base32hex ("0-9a-..."), unsigned
-// Value is a whole number of 50-bit groups ("limbs"), at least one sucb.
-//
-// The abstract value is completed by an infinite number of zero
-// limbs to the right.  Trailing zero limbs are forbidden in the
-// representation.
-//
-// Supported operations are:
-//
-//    Total ordering
-//       Values are compared lexically.
-//
-//    Select initial value:
-//       g000000000
-//
-//    Pick a value (or "n" values) strictly in between any two
-//    existing values.
-//
-//       Find first limb that they differ.  Divide intervening values
-//       for tht limb evenly (ie divide the range by n+1).  If this
-//       leaves less than an increment of 1 per output value, do
-//       differently: choose a value halfway (rounding down) for the
-//       first differeing limb, and add a new limb, whose whole range
-//       0000000000..vvvvvvvvvv is divided evenly into n+1 (thus
-//       guaranteeing that the added limb is nonzero).
-//
-//    Pick a value later than a specified value.
-//
-//       Try to add delta to rightmost nonzero limb, with carry.  If
-//       this would overflow top limb, start again: add two limbs
-//       0000000000 and then redo (this guarantees that one of the
-//       added limbs iis nonzero).  Delta is 0001000000.
-//
-//    Pick a value earlier than a specified value.
-//
-//       Try to subtract delta from rightmost nonzero limb, with
-//       borrow.  If this would underflow, or would leave leftmost
-//       limb equal to 0000000000, start again: decrement rightmost
-//       nonzero limb by 1, with borrow, then add two limbs
-//       vvvvvvvvvv, and redo.
-
 type Bigfloat = Bigfloats.Packed;
 
 namespace Bigfloats {
index 1e1141605471c6afec024e3403c0a62a90636a38..bf3a9bfb02b02332faaae1b7bf4043bff73e6161 100644 (file)
@@ -2,7 +2,66 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-// See zcoord.ts
+// This is a multiprecision sort-of-bigfloat with only a handful of
+// operations available!
+//
+// Representation, and model, ought to have these properties
+//     CBOR is binary and compact
+//  *  JSON is not lossy
+//  *  JSON is human-comprehensible
+//  *  JavaScript can compare efficiently
+//     JavaScript can do arithmetic efficiently
+//  *  Limb size is 48 for fast JS arithmetic
+//     Limb size is small for not being too full of padding
+//  *  Limb size is big so step algorithm rarely encounters limb boundaries
+//
+// Many of these are not compatible (in theory extending
+// the serde data model might help a bit, but not completely).
+// We choose those properties marked with "*".
+//
+// Main representation is a string:
+//   VVVVVVVVVV_VVVVVVVVVV ...]
+// where
+//   VVVVVVVVVV = 50 bits in lowercase base32hex ("0-9a-..."), unsigned
+// Value is a whole number of 50-bit groups ("limbs"), at least one sucb.
+//
+// The abstract value is completed by an infinite number of zero
+// limbs to the right.  Trailing zero limbs are forbidden in the
+// representation.
+//
+// Supported operations are:
+//
+//    Total ordering
+//       Values are compared lexically.
+//
+//    Select initial value:
+//       g000000000
+//
+//    Pick a value (or "n" values) strictly in between any two
+//    existing values.
+//
+//       Find first limb that they differ.  Divide intervening values
+//       for tht limb evenly (ie divide the range by n+1).  If this
+//       leaves less than an increment of 1 per output value, do
+//       differently: choose a value halfway (rounding down) for the
+//       first differeing limb, and add a new limb, whose whole range
+//       0000000000..vvvvvvvvvv is divided evenly into n+1 (thus
+//       guaranteeing that the added limb is nonzero).
+//
+//    Pick a value later than a specified value.
+//
+//       Try to add delta to rightmost nonzero limb, with carry.  If
+//       this would overflow top limb, start again: add two limbs
+//       0000000000 and then redo (this guarantees that one of the
+//       added limbs iis nonzero).  Delta is 0001000000.
+//
+//    Pick a value earlier than a specified value.
+//
+//       Try to subtract delta from rightmost nonzero limb, with
+//       borrow.  If this would underflow, or would leave leftmost
+//       limb equal to 0000000000, start again: decrement rightmost
+//       nonzero limb by 1, with borrow, then add two limbs
+//       vvvvvvvvvv, and redo.
 
 use std::cmp::{Ordering, max};
 use std::convert::{TryFrom, TryInto};