Data_encoding: better documentation of int

This commit is contained in:
Raphaël Proust 2018-04-24 14:26:00 +08:00 committed by Grégoire Henry
parent 02beb9c79a
commit 1af07b233a
2 changed files with 7 additions and 2 deletions

View File

@ -548,7 +548,7 @@ module Encoding = struct
let ranged_int minimum maximum =
let minimum = min minimum maximum
and maximum = max minimum maximum in
if minimum < ~-1_073_741_824 || 1_073_741_823 < maximum then
if minimum < -(1 lsl 30) || (1 lsl 30) - 1 < maximum then
invalid_arg "Data_encoding.ranged_int" ;
make @@ RangedInt { minimum ; maximum }
let ranged_float minimum maximum =

View File

@ -109,7 +109,12 @@ val int32 : int32 encoding
(data is encodedas a 64-bit int in binary and a decimal string in JSON). *)
val int64 : int64 encoding
(** Integer with bounds in a given range. Both bounds are inclusive *)
(** Integer with bounds in a given range. Both bounds are inclusive.
Raises [Invalid_argument] if the bounds are beyond the interval
[-2^30; 2^30-1]. These bounds are chosen to be compatible with all versions
of OCaml.
*)
val ranged_int : int -> int -> int encoding
(** Float with bounds in a given range. Both bounds are inclusive *)