This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** JavaScript-safe integer types for JSON. 7 8 These types represent integers that can be safely represented in JavaScript's 9 IEEE 754 double-precision floating point format without loss of precision. 10 The safe range is -2^53+1 to 2^53-1. 11 12 See {{:https://datatracker.ietf.org/doc/html/rfc8620#section-1.3} RFC 8620 Section 1.3}. 13 14 @canonical Jmap.Proto.Int53 *) 15 16(** 53-bit signed integer. 17 18 The range is -2^53+1 to 2^53-1, which is the safe integer range 19 for JavaScript/JSON numbers. *) 20module Signed : sig 21 type t = int64 22 (** The type of 53-bit signed integers. *) 23 24 val min_value : t 25 (** Minimum value: -9007199254740991 (-2^53+1) *) 26 27 val max_value : t 28 (** Maximum value: 9007199254740991 (2^53-1) *) 29 30 val of_int : int -> t 31 (** [of_int n] converts an OCaml int to Int53. *) 32 33 val to_int : t -> int option 34 (** [to_int n] converts to OCaml int if it fits. *) 35 36 val of_int64 : int64 -> (t, string) result 37 (** [of_int64 n] validates that [n] is in the safe range. *) 38 39 val jsont : t Jsont.t 40 (** JSON codec for 53-bit integers. Encoded as JSON number. *) 41end 42 43(** 53-bit unsigned integer. 44 45 The range is 0 to 2^53-1. *) 46module Unsigned : sig 47 type t = int64 48 (** The type of 53-bit unsigned integers. *) 49 50 val min_value : t 51 (** Minimum value: 0 *) 52 53 val max_value : t 54 (** Maximum value: 9007199254740991 (2^53-1) *) 55 56 val of_int : int -> (t, string) result 57 (** [of_int n] converts an OCaml int to UnsignedInt53. *) 58 59 val of_int64 : int64 -> (t, string) result 60 (** [of_int64 n] validates that [n] is in the valid range. *) 61 62 val jsont : t Jsont.t 63 (** JSON codec for 53-bit unsigned integers. *) 64end