Module Stdint.Int128

Contents

Instructions: Use this module in your project

In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:

  1. Add the following to your project's dependencies/CMakeLists.txt:

    Copy
    DkSDKProject_DeclareAvailable(stdint
        CONSTRAINT "= 0.7.2"
        FINDLIBS stdint)
    DkSDKProject_MakeAvailable(stdint)
  2. Add the Findlib::stdint library to any desired targets in src/*/CMakeLists.txt:

    Copy
    target_link_libraries(YourPackage_YourLibraryName
         # ... existing libraries, if any ...
         Findlib::stdint)
  3. Click your IDE's Build button

Not using DkSDK?

FIRST, do one or all of the following:

  1. Run:

    Copy
    opam install stdint.0.7.2
  2. Edit your dune-project and add:

    Copy
    (package
      (name YourExistingPackage)
      (depends
      ; ... existing dependenices ...
      (stdint (>= 0.7.2))))

    Then run:

    Copy
    dune build *.opam # if this fails, run: dune build
  3. Edit your <package>.opam file and add:

    Copy
    depends: [
      # ... existing dependencies ...
      "stdint" {>= "0.7.2"}
    ]

    Then run:

    Copy
    opam install . --deps-only

FINALLY, add the stdint library to any desired (library)and/or (executable) targets in your **/dune files:

Copy
(library
  (name YourLibrary)
  ; ... existing library options ...
  (libraries
    ; ... existing libraries ...
    stdint))

(executable
  (name YourExecutable)
  ; ... existing executable options ...
  (libraries
    ; ... existing libraries ...
    stdint))
typet`` =int128

The specific integer type

Constants
valzero :t

The value 0

valone :t

The value 1

valmax_int :t

The greatest representable integer

valmin_int :t

The smallest representable integer; for unsigned integers this is zero.

val bits : int

The number of bits used by this integer

Infix operations
val(+) :t -> t -> t

Addition

val(-) :t -> t -> t

Subtraction

val(*) :t -> t -> t

Multiplication

val(/) :t -> t -> t

Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for (/).

Arithmetic operations
valadd :t -> t -> t

Addition

valsub :t -> t -> t

Subtraction

valmul :t -> t -> t

Multiplication

valdiv :t -> t -> t

Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for (/).

valrem :t -> t -> t

Integer remainder. If y is not zero, the result of rem x y satisfies the following property: x = add (mul (div x y) y) (rem x y). If y = 0, rem x y raises Division_by_zero.

valsucc :t -> t

Successor. succ x is add x one.

valpred :t -> t

Predecessor. pred x is sub x one.

valabs :t -> t

Return the absolute value of its argument.

valneg :t -> t
Bitiwse operations
vallogand :t -> t -> t

Bitwise logical and.

vallogor :t -> t -> t

Bitwise logical or.

vallogxor :t -> t -> t

Bitwise logical exclusive or.

vallognot :t -> t

Bitwise logical negation.

valshift_left :t ->``int-> t

shift_left x y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= bits.

valshift_right :t ->``int-> t

shift_right x y shifts x to the right by y bits. If this is a signed integer, this is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= bits. For an unsigned integer, this is identical to shift_right_logical.

valshift_right_logical :t ->``int-> t

shift_right_logical x y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless if x is a signed or unsiged integer. The result is unspecified if y < 0 or y >= bits.

Numeric conversion functions
valof_int : ``int-> t

Convert the given integer (type int) to this integer type.

valto_int :t -> int

Convert the given integer (type t) to an integer of type int.

valof_float : ``float-> t

Convert the given floating-point number to an integer of type t.

valto_float :t -> float

Convert the given integer to a floating-point number.

valof_nativeint : ``nativeint-> t

Convert the given integer (type t) to a native integer.

valto_nativeint :t -> nativeint

Convert the given native integer (type nativeint) to an integer (type t.

valof_int8 :int8 -> t

Convert an integer of type int8 to an integer of type t.

valto_int8 :t -> int8

Convert an integer of type t to an integer of type int8.

valof_int16 :int16 -> t

Convert an integer of type int16 to an integer of type t.

valto_int16 :t -> int16

Convert an integer of type t to an integer of type int16.

valof_int24 :int24 -> t

Convert an integer of type int24 to an integer of type t.

valto_int24 :t -> int24

Convert an integer of type t to an integer of type int24.

valof_int32 :int32 -> t

Convert an integer of type int32 to an integer of type t.

valto_int32 :t -> int32

Convert an integer of type t to an integer of type int32.

valof_int40 :int40 -> t

Convert an integer of type int40 to an integer of type t.

valto_int40 :t -> int40

Convert an integer of type t to an integer of type int40.

valof_int48 :int48 -> t

Convert an integer of type int48 to an integer of type t.

valto_int48 :t -> int48

Convert an integer of type t to an integer of type int48.

valof_int56 :int56 -> t

Convert an integer of type int56 to an integer of type t.

valto_int56 :t -> int56

Convert an integer of type t to an integer of type int56.

valof_int64 :int64 -> t

Convert an integer of type int64 to an integer of type t.

valto_int64 :t -> int64

Convert an integer of type t to an integer of type int64.

valof_int128 :int128 -> t

Convert an integer of type int128 to an integer of type t.

valto_int128 :t -> int128

Convert an integer of type t to an integer of type int128.

valof_uint8 :uint8 -> t

Convert an integer of type uint8 to an integer of type t.

valto_uint8 :t -> uint8

Convert an integer of type t to an integer of type uint8.

valof_uint16 :uint16 -> t

Convert an integer of type uint16 to an integer of type t.

valto_uint16 :t -> uint16

Convert an integer of type t to an integer of type uint16.

valof_uint24 :uint24 -> t

Convert an integer of type uint24 to an integer of type t.

valto_uint24 :t -> uint24

Convert an integer of type t to an integer of type uint24.

valof_uint32 :uint32 -> t

Convert an integer of type uint32 to an integer of type t.

valto_uint32 :t -> uint32

Convert an integer of type t to an integer of type uint32.

valof_uint40 :uint40 -> t

Convert an integer of type uint40 to an integer of type t.

valto_uint40 :t -> uint40

Convert an integer of type t to an integer of type uint40.

valof_uint48 :uint48 -> t

Convert an integer of type uint48 to an integer of type t.

valto_uint48 :t -> uint48

Convert an integer of type t to an integer of type uint48.

valof_uint56 :uint56 -> t

Convert an integer of type uint56 to an integer of type t.

valto_uint56 :t -> uint56

Convert an integer of type t to an integer of type uint56.

valof_uint64 :uint64 -> t

Convert an integer of type uint64 to an integer of type t.

valto_uint64 :t -> uint64

Convert an integer of type t to an integer of type uint64.

valof_uint128 :uint128 -> t

Convert an integer of type uint128 to an integer of type t.

valto_uint128 :t -> uint128

Convert an integer of type t to an integer of type uint128.

String conversion functions
valof_substring : ``string->``pos:int-> t * int

Convert the given substring starting at the given offset pos to an integer of type t and return the offset. The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively. Raise Failure "*_of_substring" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type t.

valof_string : ``string-> t

Convert the given string to an integer of type t. The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively. Raise Failure "*_of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type t.

valto_string :t -> string

Return the string representation of its argument, in decimal.

valto_string_bin :t -> string

Return the string representation of its argument, in binary (beginning with 0b)

valto_string_oct :t -> string

Return the string representation of its argument, in octal (beginning with 0o)

valto_string_hex :t -> string

Return the string representation of its argument, in hex (beginning with 0x)

valprinter :Stdlib.Format.formatter -> t -> unit
valprinter_bin :Stdlib.Format.formatter -> t -> unit
valprinter_oct :Stdlib.Format.formatter -> t -> unit
valprinter_hex :Stdlib.Format.formatter -> t -> unit
Raw bytes conversion functions
valof_bytes_big_endian :Stdlib.Bytes.t ->``int-> t

of_bytes_big_endian buffer offset creates an integer value of type t from the buffer buffer starting at offset offset. The byte order is interpreted to be big endian. If the buffer does not hold enough bytes for this integer, i.e. if (Bytes.length buffer) < (offset + (bits / 8)), the function will raise Invalid_argument "index out of bounds".

valof_bytes_little_endian :Stdlib.Bytes.t ->``int-> t

of_bytes_big_endian buffer offset creates an integer value of type t from the buffer buffer starting at offset offset. The byte order is interpreted to be little endian. If the buffer does not hold enough bytes for this integer, i.e. if (Bytes.length buffer) < (offset + (bits / 8)), the function will raise Invalid_argument "index out of bounds".

valto_bytes_big_endian :t -> Stdlib.Bytes.t ->``int-> unit

to_bytes_big_endian i buffer offset writes the integer i to the buffer buffer starting at offset offset. The byte order used is big endian. If the buffer does not hold enough bytes, i.e. if (Bytes.length buffer) < (offset + (bits / 8)), the function will raise Invalid_argument "index out of bounds".

valto_bytes_little_endian :t -> Stdlib.Bytes.t ->``int-> unit

to_bytes_little_endian i buffer offset writes the integer i to the buffer buffer starting at offset offset. The byte order used is little endian. If the buffer does not hold enough bytes, i.e. if (Bytes.length buffer) < (offset + (bits / 8)), the function will raise Invalid_argument "index out of bounds".

Comparison function
valcompare :t -> t -> int

The comparison function for integers of type t, with the same specification as compare. Along with the type t, this function compare allows this module to be passed as argument to the functors Set.Make and Map.Make.

More from the DkSDK Book

    1. DkSDK
      1. Package capnp
        1. Module Capnp
            1. Module type MessageSig.MESSAGE
            1. Module type MessageSig.S
              1. Module S.ListStorage
              1. Module S.Message
              1. Module S.Object
              1. Module S.Segment
              1. Module S.Slice
              1. Module S.StructStorage
            1. Module type MessageSig.SEGMENT
            1. Module type MessageSig.SLICE
        1. Module Capnp_unix
      1. Package cmdliner
        1. Module Cmdliner
        1. Module Cmdliner_arg
        1. Module Cmdliner_base
        1. Module Cmdliner_cline
        1. Module Cmdliner_cmd
        1. Module Cmdliner_docgen
        1. Module Cmdliner_eval
        1. Module Cmdliner_info
        1. Module Cmdliner_manpage
        1. Module Cmdliner_msg
        1. Module Cmdliner_term
        1. Module Cmdliner_term_deprecated
        1. Module Cmdliner_trie
      1. Package fmt
        1. Module Fmt
        1. Module Fmt_cli
        1. Module Fmt_tty
      1. Package logs
        1. Module Logs
          1. Module type Logs.LOG
          1. ...
        1. Module Logs_cli
        1. Module Logs_fmt
        1. Module Logs_lwt
          1. Module type Logs_lwt.LOG
        1. Module Logs_threaded
      1. Package lwt
        1. Module Lwt
        1. Module Lwt_bytes
        1. Module Lwt_condition
        1. Module Lwt_config
        1. Module Lwt_engine
        1. Module Lwt_features
        1. Module Lwt_fmt
        1. Module Lwt_gc
        1. Module Lwt_io
            1. Module type Lwt_io.NumberIO
        1. Module Lwt_list
        1. Module Lwt_main
            1. Module type Lwt_main.Hooks
        1. Module Lwt_mutex
        1. Module Lwt_mvar
        1. Module Lwt_pool
        1. Module Lwt_pqueue
            1. Module type Lwt_pqueue.OrderedType
            1. Module type Lwt_pqueue.S
        1. Module Lwt_preemptive
        1. Module Lwt_process
        1. Module Lwt_result
        1. Module Lwt_seq
        1. Module Lwt_sequence
        1. Module Lwt_stream
        1. Module Lwt_switch
        1. Module Lwt_sys
        1. Module Lwt_throttle
            1. Module type Lwt_throttle.S
        1. Module Lwt_timeout
        1. Module Lwt_unix
      1. Package mtime
        1. Module Mtime
        1. Module Mtime_clock
      1. Package ocaml
        1. Module Bigarray
        1. Module Condition
        1. Module Dynlink
        1. Module Event
        1. Module Mutex
        1. Module Profiling
        1. Module Semaphore
        1. Module Stdlib
        1. Module Str
        1. Module Thread
        1. Module ThreadUnix
        1. Module Topdirs
        1. Module Unix
        1. Module UnixLabels
      1. Package
      1. Package result
        1. Module Result
      1. Package stdint
        1. Module Stdint
          1. ...
          1. Module Stdint.Int128
            1. Module type Stdint.Int