Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
Go
Haskell
HLSL
Hook
Hylo
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
WASM
Zig
Javascript
GIMPLE
c++ source #3
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 14.1.0
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 14.1.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF gcc 13.1.0
BPF gcc 13.2.0
BPF gcc 13.3.0
BPF gcc trunk
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
FRC 2019
FRC 2020
FRC 2023
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 14.1.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 14.1.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.3
x86 nvc++ 24.5
x86-64 Zapcc 190308
x86-64 clang (amd-stg-open)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (dascandy contracts)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2996)
x86-64 clang (experimental P3068)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (experimental pattern matching)
x86-64 clang (old concepts branch)
x86-64 clang (reflection)
x86-64 clang (resugar)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.4
x86-64 gcc 10.5
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 11.4
x86-64 gcc 12.1
x86-64 gcc 12.2
x86-64 gcc 12.3
x86-64 gcc 13.1
x86-64 gcc 13.2
x86-64 gcc 13.3
x86-64 gcc 14.1
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx (latest)
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
/** * @file uint256_t.cxx * @author your name (you@domain.com) * @brief * @version 0.1 * @date 2022-07-23 * @copyright Copyright (c) 2022 * @details unsigned 256 bit integer type for C++ */ #include "uint256_t.hxx" #include <array> // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- const uint128_t uint128_64(64); // ---------------------------------------------------------------------------- const uint128_t uint128_128(128); // ---------------------------------------------------------------------------- const uint128_t uint128_256(256); // ---------------------------------------------------------------------------- const uint256_t uint256_0(0); // ---------------------------------------------------------------------------- const uint256_t uint256_1(1); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // CONSTRUCTORS // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t::uint256_t() : m_upper(uint128_0) , m_lower(uint128_0) {} // ---------------------------------------------------------------------------- uint256_t::uint256_t(const uint256_t &rhs) : m_upper(rhs.m_upper) , m_lower(rhs.m_lower) {} // ---------------------------------------------------------------------------- uint256_t::uint256_t(uint256_t &&rhs) : m_upper(std::move(rhs.m_upper)) , m_lower(std::move(rhs.m_lower)) { if (this != &rhs) { rhs.m_upper = uint128_0; rhs.m_lower = uint128_0; } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ASSIGNMENT OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator=(const uint256_t &rhs) { m_upper = rhs.m_upper; m_lower = rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator=(uint256_t &&rhs) { if (this != &rhs) { m_upper = std::move(rhs.m_upper); m_lower = std::move(rhs.m_lower); rhs.m_upper = uint128_0; rhs.m_lower = uint128_0; } return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // TYPECAST OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t::operator bool() const { return (bool)(m_upper | m_lower); } // ---------------------------------------------------------------------------- uint256_t::operator uint8_t() const { return (uint8_t)m_lower; } // ---------------------------------------------------------------------------- uint256_t::operator uint16_t() const { return (uint16_t)m_lower; } // ---------------------------------------------------------------------------- uint256_t::operator uint32_t() const { return (uint32_t)m_lower; } // ---------------------------------------------------------------------------- uint256_t::operator uint64_t() const { return (uint64_t)m_lower; } // ---------------------------------------------------------------------------- uint256_t::operator uint128_t() const { return m_lower; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // BITWISE MEMBER OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t uint256_t::operator&(const uint128_t &rhs) const { return uint256_t(uint128_0, m_lower & rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator&(const uint256_t &rhs) const { return uint256_t(m_upper & rhs.m_upper, m_lower & rhs.m_lower); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator&=(const uint128_t &rhs) { m_upper = uint128_0; m_lower &= rhs; return *this; } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator&=(const uint256_t &rhs) { m_upper &= rhs.m_upper; m_lower &= rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator|(const uint128_t &rhs) const { return uint256_t(m_upper, m_lower | rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator|(const uint256_t &rhs) const { return uint256_t(m_upper | rhs.m_upper, m_lower | rhs.m_lower); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator|=(const uint128_t &rhs) { m_lower |= rhs; return *this; } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator|=(const uint256_t &rhs) { m_upper |= rhs.m_upper; m_lower |= rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator^(const uint128_t &rhs) const { return uint256_t(m_upper, m_lower ^ rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator^(const uint256_t &rhs) const { return uint256_t(m_upper ^ rhs.m_upper, m_lower ^ rhs.m_lower); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator^=(const uint128_t &rhs) { m_lower ^= rhs; return *this; } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator^=(const uint256_t &rhs) { m_upper ^= rhs.m_upper; m_lower ^= rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator~() const { return uint256_t(~m_upper, ~m_lower); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // BITSHIFT MEMBER OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t uint256_t::operator<<(const uint128_t &rhs) const { return *this << uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator<<(const uint256_t &rhs) const { const uint128_t shift = rhs.m_lower; if ( ( (bool)rhs.m_upper ) || ( shift >= uint128_256 ) ) { return uint256_0; } else if (shift == uint128_128) { return uint256_t(m_lower, uint128_0); } else if (shift == uint128_0) { return *this; } else if (shift < uint128_128) { return uint256_t((m_upper << shift) + (m_lower >> (uint128_128 - shift)), ( m_lower << shift )); } else if ((uint128_256 > shift) && (shift > uint128_128)) { return uint256_t(m_lower << (shift - uint128_128), uint128_0); } else { return uint256_0; } } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator<<=(const uint128_t &shift) { return *this <<= uint256_t(shift); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator<<=(const uint256_t &shift) { *this = *this << shift; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator>>(const uint128_t &rhs) const { return *this >> uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator>>(const uint256_t &rhs) const { const uint128_t shift = rhs.m_lower; if ( ( (bool)rhs.m_upper ) | ( shift >= uint128_256 ) ) { return uint256_0; } else if (shift == uint128_128) { return uint256_t(m_upper); } else if (shift == uint128_0) { return *this; } else if (shift < uint128_128) { return uint256_t(m_upper >> shift, (m_upper << (uint128_128 - shift)) + (m_lower >> shift)); } else if ((uint128_256 > shift) && (shift > uint128_128)) { return uint256_t(m_upper >> (shift - uint128_128)); } else { return uint256_0; } } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator>>=(const uint128_t &shift) { return *this >>= uint256_t(shift); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator>>=(const uint256_t &shift) { *this = *this >> shift; return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // LOGICAL MEMBER OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool uint256_t::operator!() const { return !(bool)*this; } // ---------------------------------------------------------------------------- bool uint256_t::operator&&(const uint128_t &rhs) const { return (*this && uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator&&(const uint256_t &rhs) const { return ((bool)*this && (bool)rhs); } // ---------------------------------------------------------------------------- bool uint256_t::operator||(const uint128_t &rhs) const { return (*this || uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator||(const uint256_t &rhs) const { return ((bool)*this || (bool)rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // COMPARAISON MEMBER OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool uint256_t::operator==(const uint128_t &rhs) const { return (*this == uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator==(const uint256_t &rhs) const { return ((m_upper == rhs.m_upper) && (m_lower == rhs.m_lower)); } // ---------------------------------------------------------------------------- bool uint256_t::operator!=(const uint128_t &rhs) const { return (*this != uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator!=(const uint256_t &rhs) const { return ((m_upper != rhs.m_upper) | (m_lower != rhs.m_lower)); } // ---------------------------------------------------------------------------- bool uint256_t::operator>(const uint128_t &rhs) const { return (*this > uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator>(const uint256_t &rhs) const { if (m_upper == rhs.m_upper) { return (m_lower > rhs.m_lower); } if (m_upper > rhs.m_upper) { return true; } return false; } // ---------------------------------------------------------------------------- bool uint256_t::operator<(const uint128_t &rhs) const { return (*this < uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator<(const uint256_t &rhs) const { if (m_upper == rhs.m_upper) { return (m_lower < rhs.m_lower); } if (m_upper < rhs.m_upper) { return true; } return false; } // ---------------------------------------------------------------------------- bool uint256_t::operator>=(const uint128_t &rhs) const { return (*this >= uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator>=(const uint256_t &rhs) const { return ((*this > rhs) | (*this == rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator<=(const uint128_t &rhs) const { return (*this <= uint256_t(rhs)); } // ---------------------------------------------------------------------------- bool uint256_t::operator<=(const uint256_t &rhs) const { return ((*this < rhs) | (*this == rhs)); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ARITHMETIC MEMBER OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t uint256_t::operator+(const uint128_t &rhs) const { return *this + uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator+(const uint256_t &rhs) const { return uint256_t( m_upper + rhs.m_upper + (( (m_lower + rhs.m_lower) < m_lower ) ? uint128_1 : uint128_0 ), m_lower + rhs.m_lower); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator+=(const uint128_t &rhs) { return *this += uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator+=(const uint256_t &rhs) { m_upper = rhs.m_upper + m_upper + ((m_lower + rhs.m_lower) < m_lower); m_lower = m_lower + rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator-(const uint128_t &rhs) const { return *this - uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator-(const uint256_t &rhs) const { return uint256_t(m_upper - rhs.m_upper - ((m_lower - rhs.m_lower) > m_lower), m_lower - rhs.m_lower); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator-=(const uint128_t &rhs) { return *this -= uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator-=(const uint256_t &rhs) { *this = *this - rhs; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator*(const uint128_t &rhs) const { return *this * uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator*(const uint256_t &rhs) const { // split values into 4 64-bit parts std::array<uint128_t, 4> top { m_upper.upper(), m_upper.lower(), m_lower.upper(), m_lower.lower() }; std::array<uint128_t ,4> bottom { rhs.upper().upper(), rhs.upper().lower(), rhs.lower().upper(), rhs.lower().lower() }; std::array<std::array<uint128_t, 4>, 4> products; // multiply each component of the values for (int y = 3; y > -1; y--) { for (int x = 3; x > -1; x--) { products[3 - y][x] = top[x] * bottom[y]; } } // first row uint128_t fourth64 = uint128_t(products[0][3].lower()); uint128_t third64 = uint128_t(products[0][2].lower()) + uint128_t(products[0][3].upper()); uint128_t second64 = uint128_t(products[0][1].lower()) + uint128_t(products[0][2].upper()); uint128_t first64 = uint128_t(products[0][0].lower()) + uint128_t(products[0][1].upper()); // second row third64 += uint128_t(products[1][3].lower()); second64 += uint128_t(products[1][2].lower()) + uint128_t(products[1][3].upper()); first64 += uint128_t(products[1][1].lower()) + uint128_t(products[1][2].upper()); // third row second64 += uint128_t(products[2][3].lower()); first64 += uint128_t(products[2][2].lower()) + uint128_t(products[2][3].upper()); // fourth row first64 += uint128_t(products[3][3].lower()); // combines the values, taking care of carry over return uint256_t(first64 << uint128_64, uint128_0) + uint256_t(third64.upper(), third64 << uint128_64) + uint256_t(second64, uint128_0) + uint256_t(fourth64); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator*=(const uint128_t &rhs) { return *this *= uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator*=(const uint256_t &rhs) { *this = *this * rhs; return *this; } // ---------------------------------------------------------------------------- std::pair<uint256_t, uint256_t> uint256_t::divmod(const uint256_t &lhs, const uint256_t &rhs) const { // Save some calculations ///////////////////// if (rhs == uint256_0) { throw std::domain_error("Error: division or modulus by 0"); } else if (rhs == uint256_1) { return std::pair<uint256_t, uint256_t>(lhs, uint256_0); } else if (lhs == rhs) { return std::pair<uint256_t, uint256_t>(uint256_1, uint256_0); } else if ((lhs == uint256_0) || (lhs < rhs)) { return std::pair<uint256_t, uint256_t>(uint256_0, lhs); } std::pair<uint256_t, uint256_t> qr(uint256_0, lhs); uint256_t copyd = rhs << (lhs.bits() - rhs.bits()); uint256_t adder = uint256_1 << (lhs.bits() - rhs.bits()); if (copyd > qr.second) { copyd >>= uint256_1; adder >>= uint256_1; } while (qr.second >= rhs) { if (qr.second >= copyd) { qr.second -= copyd; qr.first |= adder; } copyd >>= uint256_1; adder >>= uint256_1; } return qr; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator/(const uint128_t &rhs) const { return *this / uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator/(const uint256_t &rhs) const { return divmod(*this, rhs).first; } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator/=(const uint128_t &rhs) { return *this /= uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator/=(const uint256_t &rhs) { *this = *this / rhs; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator%(const uint128_t &rhs) const { return *this % uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator%(const uint256_t &rhs) const { return *this - (rhs * (*this / rhs)); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator%=(const uint128_t &rhs) { return *this %= uint256_t(rhs); } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator%=(const uint256_t &rhs) { *this = *this % rhs; return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // INCREMENT & DECREMENT MEMBER OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator++() { *this += uint256_1; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator++(int) { uint256_t temp(*this); ++*this; return temp; } // ---------------------------------------------------------------------------- uint256_t &uint256_t::operator--() { *this -= uint256_1; return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator--(int) { uint256_t temp(*this); --*this; return temp; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t uint256_t::operator+() const { return *this; } // ---------------------------------------------------------------------------- uint256_t uint256_t::operator-() const { return ~*this + uint256_1; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // GETTER // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- const uint128_t &uint256_t::upper() const { return m_upper; } // ---------------------------------------------------------------------------- const uint128_t &uint256_t::lower() const { return m_lower; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint16_t uint256_t::bits() const { uint16_t out = 0; if (m_upper) { out = 128; uint128_t up = m_upper; while (up) { up >>= uint128_1; out++; } } else { uint128_t low = m_lower; while (low) { low >>= uint128_1; out++; } } return out; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::string uint256_t::str(uint8_t base, const unsigned int &len) const { if ((base < 2) || (base > 36)) { throw std::invalid_argument("Base must be in the range 2-36"); } std::string out = ""; if (!(*this)) { out = std::string("0"); } else { std::pair<uint256_t, uint256_t> qr(*this, uint256_0); do{ qr = divmod(qr.first, base); out = "0123456789abcdefghijklmnopqrstuvwxyz"[(uint8_t)qr.second] + out; } while (qr.first); } if (out.size() < len) { out = std::string(len - out.size(), '0') + out; } return out; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // BITWISE OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator&(const uint128_t &lhs, const uint256_t &rhs) { return rhs & lhs; } // ---------------------------------------------------------------------------- uint128_t &operator&=(uint128_t &lhs, const uint256_t &rhs) { lhs = (rhs & lhs).lower(); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator|(const uint128_t &lhs, const uint256_t &rhs) { return rhs | lhs; } // ---------------------------------------------------------------------------- uint128_t &operator|=(uint128_t &lhs, const uint256_t &rhs) { lhs = (rhs | lhs).lower(); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator^(const uint128_t &lhs, const uint256_t &rhs) { return rhs ^ lhs; } // ---------------------------------------------------------------------------- uint128_t &operator^=(uint128_t &lhs, const uint256_t &rhs) { lhs = (rhs ^ lhs).lower(); return lhs; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // BITSHIFT OPERATOR // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator<<(const bool &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const uint8_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const uint16_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const uint32_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const uint64_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const uint128_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const int8_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const int16_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const int32_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint256_t operator<<(const int64_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t &operator<<=(uint128_t &lhs, const uint256_t &rhs) { lhs = (uint256_t(lhs) << rhs).lower(); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const bool &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const uint8_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const uint16_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const uint32_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const uint64_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const uint128_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const int8_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const int16_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const int32_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const int64_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t &operator>>=(uint128_t &lhs, const uint256_t &rhs) { lhs = (uint256_t(lhs) >> rhs).lower(); return lhs; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Comparison Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool operator==(const uint128_t &lhs, const uint256_t &rhs) { return rhs == lhs; } // ---------------------------------------------------------------------------- bool operator!=(const uint128_t &lhs, const uint256_t &rhs) { return rhs != lhs; } // ---------------------------------------------------------------------------- bool operator>(const uint128_t &lhs, const uint256_t &rhs) { return rhs < lhs; } // ---------------------------------------------------------------------------- bool operator<(const uint128_t &lhs, const uint256_t &rhs) { return rhs > lhs; } // ---------------------------------------------------------------------------- bool operator>=(const uint128_t &lhs, const uint256_t &rhs) { return rhs <= lhs; } // ---------------------------------------------------------------------------- bool operator<=(const uint128_t &lhs, const uint256_t &rhs) { return rhs >= lhs; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Arithmetic Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator+(const uint128_t &lhs, const uint256_t &rhs) { return rhs + lhs; } // ---------------------------------------------------------------------------- uint128_t &operator+=(uint128_t &lhs, const uint256_t &rhs) { lhs = (rhs + lhs).lower(); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator-(const uint128_t &lhs, const uint256_t &rhs) { return -(rhs - lhs); } // ---------------------------------------------------------------------------- uint128_t &operator-=(uint128_t &lhs, const uint256_t &rhs) { lhs = (-(rhs - lhs)).lower(); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator*(const uint128_t &lhs, const uint256_t &rhs) { return rhs * lhs; } // ---------------------------------------------------------------------------- uint128_t &operator*=(uint128_t &lhs, const uint256_t &rhs) { lhs = (rhs * lhs).lower(); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator/(const uint128_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) / rhs; } // ---------------------------------------------------------------------------- uint128_t &operator/=(uint128_t &lhs, const uint256_t &rhs) { lhs = (uint256_t(lhs) / rhs).lower(); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator%(const uint128_t &lhs, const uint256_t &rhs) { return uint256_t(lhs) % rhs; } // ---------------------------------------------------------------------------- uint128_t &operator%=(uint128_t &lhs, const uint256_t &rhs) { lhs = (uint256_t(lhs) % rhs).lower(); return lhs; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // IO STREAM // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::ostream &operator<<(std::ostream &stream, const uint256_t &rhs) { if (stream.flags() & stream.oct) { stream << rhs.str(8); } else if (stream.flags() & stream.dec) { stream << rhs.str(10); } else if (stream.flags() & stream.hex) { stream << rhs.str(16); } return stream; } // ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
c++ source #6
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 14.1.0
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 14.1.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF gcc 13.1.0
BPF gcc 13.2.0
BPF gcc 13.3.0
BPF gcc trunk
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
FRC 2019
FRC 2020
FRC 2023
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 14.1.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 14.1.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.3
x86 nvc++ 24.5
x86-64 Zapcc 190308
x86-64 clang (amd-stg-open)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (dascandy contracts)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2996)
x86-64 clang (experimental P3068)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (experimental pattern matching)
x86-64 clang (old concepts branch)
x86-64 clang (reflection)
x86-64 clang (resugar)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.4
x86-64 gcc 10.5
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 11.4
x86-64 gcc 12.1
x86-64 gcc 12.2
x86-64 gcc 12.3
x86-64 gcc 13.1
x86-64 gcc 13.2
x86-64 gcc 13.3
x86-64 gcc 14.1
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx (latest)
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
#include "uint256_t.hxx" #include <iostream> auto main() -> int { const uint128_t num1(0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL); std::cout << "---------------------------\xa\xa"; std::cout << "value -> " << num1 << '\xa'; std::cout << "sizee -> " << sizeof(num1) << '\xa'; std::cout << "sizee -> " << sizeof(uint128_t) << '\xa'; std::cout << "\xa---------------------------\xa"; std::cout << "---------------------------\xa\xa"; const uint256_t num2( 0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL ); std::cout << "value -> " << num2 << '\xa'; std::cout << "sizee -> " << sizeof(num2) << '\xa'; std::cout << "sizee -> " << sizeof(uint256_t) << '\xa'; std::cout << "\xa---------------------------\xa"; }
c++ source #4
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 14.1.0
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 14.1.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF gcc 13.1.0
BPF gcc 13.2.0
BPF gcc 13.3.0
BPF gcc trunk
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
FRC 2019
FRC 2020
FRC 2023
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 14.1.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 14.1.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.3
x86 nvc++ 24.5
x86-64 Zapcc 190308
x86-64 clang (amd-stg-open)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (dascandy contracts)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2996)
x86-64 clang (experimental P3068)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (experimental pattern matching)
x86-64 clang (old concepts branch)
x86-64 clang (reflection)
x86-64 clang (resugar)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.4
x86-64 gcc 10.5
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 11.4
x86-64 gcc 12.1
x86-64 gcc 12.2
x86-64 gcc 12.3
x86-64 gcc 13.1
x86-64 gcc 13.2
x86-64 gcc 13.3
x86-64 gcc 14.1
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx (latest)
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
/** * @file uint256_t.hpp * @author your name (you@domain.com) * @brief * @version 0.1 * @date 2022-07-23 * @copyright Copyright (c) 2022 * @details unsigned 256 bit integer type for C++ */ #ifndef _UINT256_T_HXX #define _UINT256_T_HXX #include "uint128_t.hxx" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- class uint256_t; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Give uint256_t type traits namespace std { // This is probably not a good idea // ---------------------------------------------------------------------------- template <> struct is_arithmetic<uint256_t> : std::true_type {}; // ---------------------------------------------------------------------------- template <> struct is_integral<uint256_t> : std::true_type {}; // ---------------------------------------------------------------------------- template <> struct is_unsigned<uint256_t> : std::true_type {}; // ---------------------------------------------------------------------------- } // namespace std // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- class uint256_t { private: uint128_t m_upper, m_lower; public: // ---------------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t(); // ---------------------------------------------------------------------------- uint256_t(const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t(uint256_t &&rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t(const T &rhs); // ---------------------------------------------------------------------------- template <std::integral S, std::integral T> uint256_t(const S &upper_rhs, const T &lower_rhs); // ---------------------------------------------------------------------------- template <std::integral R, std::integral S, std::integral T, std::integral U> uint256_t(const R &upper_lhs, const S &lower_lhs, const T &upper_rhs, const U &lower_rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // RHS input args only // ---------------------------------------------------------------------------- // Assignment Operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t &operator=(const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator=(uint256_t &&rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t& operator=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Typecast Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- operator bool() const; // ---------------------------------------------------------------------------- operator uint8_t() const; // ---------------------------------------------------------------------------- operator uint16_t() const; // ---------------------------------------------------------------------------- operator uint32_t() const; // ---------------------------------------------------------------------------- operator uint64_t() const; // ---------------------------------------------------------------------------- operator uint128_t() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitwise Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator&(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator&(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator&(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator&=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator&=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator&=(const T &rhs); // ---------------------------------------------------------------------------- uint256_t operator|(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator|(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator|(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator|=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator|=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator|=(const T &rhs); // ---------------------------------------------------------------------------- uint256_t operator^(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator^(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator^(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator^=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator^=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator^=(const T &rhs); // ---------------------------------------------------------------------------- uint256_t operator~() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bit Shift Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator<<(const uint128_t &shift) const; // ---------------------------------------------------------------------------- uint256_t operator<<(const uint256_t &shift) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator<<(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator<<=(const uint128_t &shift); // ---------------------------------------------------------------------------- uint256_t &operator<<=(const uint256_t &shift); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator<<=(const T &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const uint128_t &shift) const; // ---------------------------------------------------------------------------- uint256_t operator>>(const uint256_t &shift) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator>>(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator>>=(const uint128_t &shift); // ---------------------------------------------------------------------------- uint256_t &operator>>=(const uint256_t &shift); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator>>=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Logical Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool operator!() const; // ---------------------------------------------------------------------------- bool operator&&(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator&&(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator&&(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator||(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator||(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator||(const T &rhs) const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Comparison Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool operator==(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator==(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator==(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator!=(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator!=(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator!=(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator>(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator>(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator>(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator<(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator<(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator<(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator>=(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator>=(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator>=(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator<=(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator<=(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator<=(const T &rhs) const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Arithmetic Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator+(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator+(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator+(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator+=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator+=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator+=(const T &rhs); // ---------------------------------------------------------------------------- uint256_t operator-(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator-(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator-(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator-=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator-=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator-=(const T &rhs); // ---------------------------------------------------------------------------- uint256_t operator*(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator*(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator*(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator*=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator*=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator*=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- private: // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::pair<uint256_t, uint256_t> divmod(const uint256_t &lhs,const uint256_t &rhs) const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- public: // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator/(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator/(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator/(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator/=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator/=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator/=(const T &rhs); // ---------------------------------------------------------------------------- uint256_t operator%(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- uint256_t operator%(const uint256_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator%(const T &rhs) const; // ---------------------------------------------------------------------------- uint256_t &operator%=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint256_t &operator%=(const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &operator%=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Increment Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t &operator++(); // ---------------------------------------------------------------------------- uint256_t operator++(int); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Decrement Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t &operator--(); // ---------------------------------------------------------------------------- uint256_t operator--(int); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Nothing done since promotion doesn't work here uint256_t operator+() const; // ---------------------------------------------------------------------------- // two's complement uint256_t operator-() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Get private values // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- const uint128_t &upper() const; // ---------------------------------------------------------------------------- const uint128_t &lower() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Get bitsize of value // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint16_t bits() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Get string representation of value // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::string str(uint8_t base = 10, const unsigned int &len = 0) const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- }; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- extern const uint128_t uint128_64; // ---------------------------------------------------------------------------- extern const uint128_t uint128_128; // ---------------------------------------------------------------------------- extern const uint128_t uint128_256; // ---------------------------------------------------------------------------- extern const uint256_t uint256_0; // ---------------------------------------------------------------------------- extern const uint256_t uint256_1; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint256_t::uint256_t(const T &rhs) : m_upper(uint128_0) , m_lower(rhs) {} // ---------------------------------------------------------------------------- template <std::integral S, std::integral T> uint256_t::uint256_t(const S &upper_rhs, const T &lower_rhs) : m_upper(upper_rhs) , m_lower(lower_rhs) {} // ---------------------------------------------------------------------------- template <std::integral R, std::integral S, std::integral T, std::integral U> uint256_t::uint256_t(const R &upper_lhs, const S &lower_lhs, const T &upper_rhs, const U &lower_rhs) : m_upper(upper_lhs, lower_lhs) , m_lower(upper_rhs, lower_rhs) {} // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Assignment operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint256_t& uint256_t::operator=(const T &rhs) { m_upper = uint128_0; m_lower = rhs; return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitwise member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator&(const T &rhs) const { return uint256_t(uint128_0, m_lower & (uint128_t)rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator&=(const T &rhs) { m_upper = uint128_0; m_lower &= rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator|(const T &rhs) const { return uint256_t(m_upper, m_lower | uint128_t(rhs)); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator|=(const T &rhs) { m_lower |= (uint128_t)rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator^(const T &rhs) const { return uint256_t(m_upper, m_lower ^ (uint128_t)rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator^=(const T &rhs) { m_lower ^= (uint128_t)rhs; return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitwise Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator&(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator&(const T &lhs, const uint256_t &rhs) { return rhs & lhs; } // ---------------------------------------------------------------------------- uint128_t &operator&=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator&=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(rhs & lhs); } // ---------------------------------------------------------------------------- uint256_t operator|(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator|(const T &lhs, const uint256_t &rhs) { return rhs | lhs; } // ---------------------------------------------------------------------------- uint128_t &operator|=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator|=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(rhs | lhs); } // ---------------------------------------------------------------------------- uint256_t operator^(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator^(const T &lhs, const uint256_t &rhs) { return rhs ^ lhs; } // ---------------------------------------------------------------------------- uint128_t &operator^=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator^=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(rhs ^ lhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bit Shift member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator<<(const T &rhs) const { return *this << uint256_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator<<=(const T &rhs) { *this = *this << uint256_t(rhs); return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator>>(const T &rhs) const { return *this >> uint256_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator>>=(const T &rhs) { *this = *this >> uint256_t(rhs); return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitshift operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator<<(const bool &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const uint8_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const uint16_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const uint32_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const uint64_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const int8_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const int16_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const int32_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator<<(const int64_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint128_t &operator<<=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator<<=(T &lhs, const uint256_t &rhs) { lhs = static_cast<T>(uint256_t(lhs) << rhs); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator>>(const bool &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const uint8_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const uint16_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const uint32_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const uint64_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const int8_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const int16_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const int32_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint256_t operator>>(const int64_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- uint128_t &operator>>=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator>>=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(uint256_t(lhs) >> rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Comparison member Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator==(const T &rhs) const { return (!m_upper && (m_lower == uint128_t(rhs))); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator!=(const T &rhs) const { return ((bool)m_upper | (m_lower != uint128_t(rhs))); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator>(const T &rhs) const { return ((bool)m_upper | (m_lower > uint128_t(rhs))); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator<(const T &rhs) const { return (!m_upper) ? (m_lower < uint128_t(rhs)) : false; } // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator>=(const T &rhs) const { return ((*this > rhs) | (*this == rhs)); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator<=(const T &rhs) const { return ((*this < rhs) | (*this == rhs)); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Comparison Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool operator==(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> bool operator==(const T &lhs, const uint256_t &rhs) { return (!rhs.upper() && ((uint64_t)lhs == rhs.lower())); } // ---------------------------------------------------------------------------- bool operator!=(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> bool operator!=(const T &lhs, const uint256_t &rhs) { return (rhs.upper() | ((uint64_t)lhs != rhs.lower())); } // ---------------------------------------------------------------------------- bool operator>(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> bool operator>(const T &lhs, const uint256_t &rhs) { return rhs.upper() ? false : ((uint128_t)lhs > rhs.lower()); } // ---------------------------------------------------------------------------- bool operator<(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> bool operator<(const T &lhs, const uint256_t &rhs) { return rhs.upper() ? true : ((uint128_t)lhs < rhs.lower()); } // ---------------------------------------------------------------------------- bool operator>=(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> bool operator>=(const T &lhs, const uint256_t &rhs) { return rhs.upper() ? false : ((uint128_t)lhs >= rhs.lower()); } // ---------------------------------------------------------------------------- bool operator<=(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> bool operator<=(const T &lhs, const uint256_t &rhs) { return rhs.upper() ? true : ((uint128_t)lhs <= rhs.lower()); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Arithmetic member Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator+(const T &rhs) const { return uint256_t(m_upper + ((m_lower + (uint128_t)rhs) < m_lower), m_lower + (uint128_t)rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator+=(const T &rhs) { m_upper = m_upper + ((m_lower + rhs) < m_lower); m_lower = m_lower + rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator-(const T &rhs) const { return uint256_t(m_upper - ((m_lower - rhs) > m_lower), m_lower - rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator-=(const T &rhs) { *this = *this - rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator*(const T &rhs) const { return *this * uint256_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator*=(const T &rhs) { *this = *this * uint256_t(rhs); return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator/(const T &rhs) const { return *this / uint256_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator/=(const T &rhs) { *this = *this / uint256_t(rhs); return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t uint256_t::operator%(const T &rhs) const { return *this % uint256_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint256_t &uint256_t::operator%=(const T &rhs) { *this = *this % uint256_t(rhs); return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Arithmetic Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint256_t operator+(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator+(const T &lhs, const uint256_t &rhs) { return rhs + lhs; } // ---------------------------------------------------------------------------- uint128_t &operator+=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator+=(T &lhs, const uint256_t &rhs) { lhs = static_cast<T>(rhs + lhs); return lhs; } // ---------------------------------------------------------------------------- uint256_t operator-(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator-(const T &lhs, const uint256_t &rhs) { return -(rhs - lhs); } // ---------------------------------------------------------------------------- uint128_t &operator-=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator-=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(-(rhs - lhs)); } // ---------------------------------------------------------------------------- uint256_t operator*(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator*(const T &lhs, const uint256_t &rhs) { return rhs * lhs; } // ---------------------------------------------------------------------------- uint128_t &operator*=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator*=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(rhs * lhs); } // ---------------------------------------------------------------------------- uint256_t operator/(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator/(const T &lhs, const uint256_t &rhs) { return uint256_t(lhs) / rhs; } // ---------------------------------------------------------------------------- uint128_t &operator/=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator/=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(uint256_t(lhs) / rhs); } // ---------------------------------------------------------------------------- uint256_t operator%(const uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint256_t operator%(const T &lhs, const uint256_t &rhs) { return uint256_t(lhs) % rhs; } // ---------------------------------------------------------------------------- uint128_t &operator%=(uint128_t &lhs, const uint256_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> T &operator%=(T &lhs, const uint256_t &rhs) { return lhs = static_cast<T>(uint256_t(lhs) % rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Logical member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator&&(const T &rhs) const { return ((bool)*this && rhs); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint256_t::operator||(const T &rhs) const { return ((bool)*this || rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // IO Operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::ostream &operator<<(std::ostream &stream, const uint256_t &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #endif
c++ source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 14.1.0
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 14.1.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF gcc 13.1.0
BPF gcc 13.2.0
BPF gcc 13.3.0
BPF gcc trunk
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
FRC 2019
FRC 2020
FRC 2023
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 14.1.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 14.1.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.3
x86 nvc++ 24.5
x86-64 Zapcc 190308
x86-64 clang (amd-stg-open)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (dascandy contracts)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2996)
x86-64 clang (experimental P3068)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (experimental pattern matching)
x86-64 clang (old concepts branch)
x86-64 clang (reflection)
x86-64 clang (resugar)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.4
x86-64 gcc 10.5
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 11.4
x86-64 gcc 12.1
x86-64 gcc 12.2
x86-64 gcc 12.3
x86-64 gcc 13.1
x86-64 gcc 13.2
x86-64 gcc 13.3
x86-64 gcc 14.1
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx (latest)
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
/** * @file uint128_t.cxx * @author your name (you@domain.com) * @brief * @version 0.1 * @date 2022-07-23 * @copyright Copyright (c) 2022 * @details An unsigned 128 bit integer type for C++ */ #include "uint128_t.hxx" #include <array> // https://godbolt.org/z/Gq65vz3W1 test // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- const uint128_t uint128_0(0); // ---------------------------------------------------------------------------- const uint128_t uint128_1(1); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // constructors // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t::uint128_t() : m_upper(0) , m_lower(0) {} // ---------------------------------------------------------------------------- uint128_t::uint128_t(const uint128_t &rhs) : m_upper(rhs.m_upper) , m_lower(rhs.m_lower) {} // ---------------------------------------------------------------------------- uint128_t::uint128_t(uint128_t &&rhs) : m_upper(std::move(rhs.m_upper)) , m_lower(std::move(rhs.m_lower)) { if (this != &rhs) { rhs.m_upper = 0; rhs.m_lower = 0; } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // assignment operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator=(const uint128_t &rhs) { m_upper = rhs.m_upper; m_lower = rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator=(uint128_t &&rhs) { if (this != &rhs) { m_upper = std::move(rhs.m_upper); m_lower = std::move(rhs.m_lower); rhs.m_upper = 0; rhs.m_lower = 0; } return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // typecast operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t::operator bool() const { return (bool)(m_upper | m_lower); } // ---------------------------------------------------------------------------- uint128_t::operator uint8_t() const { return (uint8_t)m_lower; } // ---------------------------------------------------------------------------- uint128_t::operator uint16_t() const { return (uint16_t)m_lower; } // ---------------------------------------------------------------------------- uint128_t::operator uint32_t() const { return (uint32_t)m_lower; } // ---------------------------------------------------------------------------- uint128_t::operator uint64_t() const { return (uint64_t)m_lower; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator&(const uint128_t &rhs) const { return uint128_t( ( m_upper & rhs.m_upper ), ( m_lower & rhs.m_lower ) ); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // bitwise member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator&=(const uint128_t &rhs) { m_upper &= rhs.m_upper; m_lower &= rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator|(const uint128_t &rhs) const { return uint128_t( ( m_upper | rhs.m_upper ), ( m_lower | rhs.m_lower ) ); } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator|=(const uint128_t &rhs) { m_upper |= rhs.m_upper; m_lower |= rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator^(const uint128_t &rhs) const { return uint128_t( ( m_upper ^ rhs.m_upper ), ( m_lower ^ rhs.m_lower ) ); } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator^=(const uint128_t &rhs) { m_upper ^= rhs.m_upper; m_lower ^= rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator~() const { return uint128_t(~m_upper, ~m_lower); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bit shift operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t uint128_t::operator<<(const uint128_t &rhs) const { const uint64_t shift = rhs.m_lower; if( ( (bool)rhs.m_upper ) || ( shift >= 128 ) ) { return uint128_0; } else if( shift == 64 ) { return uint128_t(m_lower, 0); } else if ( shift == 0 ) { return *this; } else if (shift < 64) { return uint128_t( ( m_upper << shift ) + ( m_lower >> ( 64 - shift ) ), ( m_lower << shift ) ); } else if ((128 > shift) && (shift > 64)) { return uint128_t( ( m_lower << (shift - 64) ), 0); } else { return uint128_0; } } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator<<=(const uint128_t &rhs) { *this = *this << rhs; return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator>>(const uint128_t &rhs) const { const uint64_t shift = rhs.m_lower; if( ((bool)rhs.m_upper) || (shift >= 128) ) { return uint128_0; } else if (shift == 64) { return uint128_t(0, m_upper); } else if (shift == 0) { return *this; } else if (shift < 64) { return uint128_t( ( m_upper >> shift ), ( m_upper << (64 - shift) ) + (m_lower >> shift) ); } else if ((128 > shift) && (shift > 64)) { return uint128_t(0, (m_upper >> (shift - 64))); } else { return uint128_0; } } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator>>=(const uint128_t &rhs) { *this = *this >> rhs; return *this; } // ---------------------------------------------------------------------------- uint128_t operator<<(const bool &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const uint8_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const uint16_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const uint32_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const uint64_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const int8_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const int16_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const int32_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator<<(const int64_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) << rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const bool &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const uint8_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const uint16_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const uint32_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const uint64_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const int8_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const int16_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const int32_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- uint128_t operator>>(const int64_t &lhs, const uint128_t &rhs) { return uint128_t(lhs) >> rhs; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Logical operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool uint128_t::operator!() const { return !(bool)(m_upper | m_lower); } // ---------------------------------------------------------------------------- bool uint128_t::operator&&(const uint128_t &rhs) const { return ((bool)*this && rhs); } // ---------------------------------------------------------------------------- bool uint128_t::operator||(const uint128_t &rhs) const { return ((bool)*this || rhs); } // ---------------------------------------------------------------------------- bool uint128_t::operator==(const uint128_t &rhs) const { return ((m_upper == rhs.m_upper) && (m_lower == rhs.m_lower)); } // ---------------------------------------------------------------------------- bool uint128_t::operator!=(const uint128_t &rhs) const { return ((m_upper != rhs.m_upper) | (m_lower != rhs.m_lower)); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Comparaison operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool uint128_t::operator>(const uint128_t &rhs) const { if (m_upper == rhs.m_upper) { return (m_lower > rhs.m_lower); } return (m_upper > rhs.m_upper); } // ---------------------------------------------------------------------------- bool uint128_t::operator<(const uint128_t &rhs) const { if (m_upper == rhs.m_upper) { return (m_lower < rhs.m_lower); } return (m_upper < rhs.m_upper); } // ---------------------------------------------------------------------------- bool uint128_t::operator>=(const uint128_t &rhs) const { return ((*this > rhs) | (*this == rhs)); } // ---------------------------------------------------------------------------- bool uint128_t::operator<=(const uint128_t &rhs) const { return ((*this < rhs) | (*this == rhs)); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Arithmetic operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t uint128_t::operator+(const uint128_t &rhs) const { return uint128_t(m_upper + rhs.m_upper + ((m_lower + rhs.m_lower) < m_lower), m_lower + rhs.m_lower); } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator+=(const uint128_t &rhs) { m_upper += rhs.m_upper + ((m_lower + rhs.m_lower) < m_lower); m_lower += rhs.m_lower; return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator-(const uint128_t &rhs) const { return uint128_t(m_upper - rhs.m_upper - ((m_lower - rhs.m_lower) > m_lower), m_lower - rhs.m_lower); } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator-=(const uint128_t &rhs) { *this = *this - rhs; return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator*(const uint128_t &rhs) const { // split values into 4 32-bit parts std::array<uint64_t, 4> top { m_upper >> 32, m_upper & 0xffffffff, m_lower >> 32, m_lower & 0xffffffff }; std::array<uint64_t, 4> bottom { rhs.m_upper >> 32, rhs.m_upper & 0xffffffff, rhs.m_lower >> 32, rhs.m_lower & 0xffffffff }; std::array<std::array<uint64_t, 4>, 4> products; // multiply each component of the values for (int y = 3; y > -1; y--) { for (int x = 3; x > -1; x--) { products[3 - x][y] = top[x] * bottom[y]; } } // first row uint64_t fourth32 = (products[0][3] & 0xffffffff); uint64_t third32 = (products[0][2] & 0xffffffff) + (products[0][3] >> 32); uint64_t second32 = (products[0][1] & 0xffffffff) + (products[0][2] >> 32); uint64_t first32 = (products[0][0] & 0xffffffff) + (products[0][1] >> 32); // second row third32 += (products[1][3] & 0xffffffff); second32 += (products[1][2] & 0xffffffff) + (products[1][3] >> 32); first32 += (products[1][1] & 0xffffffff) + (products[1][2] >> 32); // third row second32 += (products[2][3] & 0xffffffff); first32 += (products[2][2] & 0xffffffff) + (products[2][3] >> 32); // fourth row first32 += (products[3][3] & 0xffffffff); // move carry to next digit third32 += fourth32 >> 32; second32 += third32 >> 32; first32 += second32 >> 32; // remove carry from current digit fourth32 &= 0xffffffff; third32 &= 0xffffffff; second32 &= 0xffffffff; first32 &= 0xffffffff; // combine components return uint128_t((first32 << 32) | second32, (third32 << 32) | fourth32); } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator*=(const uint128_t &rhs) { *this = *this * rhs; return *this; } // ---------------------------------------------------------------------------- std::pair<uint128_t, uint128_t> uint128_t::divmod(const uint128_t &lhs, const uint128_t &rhs) const { // Save some calculations ///////////////////// if (rhs == uint128_0) { throw std::domain_error("Error: division or modulus by 0"); } else if (rhs == uint128_1) { return std::pair<uint128_t, uint128_t>(lhs, uint128_0); } else if (lhs == rhs) { return std::pair<uint128_t, uint128_t>(uint128_1, uint128_0); } else if ((lhs == uint128_0) || (lhs < rhs)) { return std::pair<uint128_t, uint128_t>(uint128_0, lhs); } std::pair<uint128_t, uint128_t> qr(uint128_0, uint128_0); for (uint8_t x = lhs.bits(); x > 0; x--) { qr.first <<= uint128_1; qr.second <<= uint128_1; if ( ( lhs >> (x - 1U) ) & 1 ) { qr.second++; } if (qr.second >= rhs) { qr.second -= rhs; qr.first++; } } return qr; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator/(const uint128_t &rhs) const { return divmod(*this, rhs).first; } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator/=(const uint128_t &rhs) { *this = *this / rhs; return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator%(const uint128_t &rhs) const { return divmod(*this, rhs).second; } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator%=(const uint128_t &rhs) { *this = *this % rhs; return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Increment operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator++() { return *this += uint128_1; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator++(int) { uint128_t temp(*this); ++*this; return temp; } // ---------------------------------------------------------------------------- uint128_t &uint128_t::operator--() { return *this -= uint128_1; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator--(int) { uint128_t temp(*this); --*this; return temp; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t uint128_t::operator+() const { return *this; } // ---------------------------------------------------------------------------- uint128_t uint128_t::operator-() const { return ~*this + uint128_1; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Getter // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- const uint64_t &uint128_t::upper() const { return m_upper; } // ---------------------------------------------------------------------------- const uint64_t &uint128_t::lower() const { return m_lower; } // ---------------------------------------------------------------------------- uint8_t uint128_t::bits() const { uint8_t out = 0; if (m_upper) { out = 64; uint64_t up = m_upper; while (up) { up >>= 1; out++; } } else { uint64_t low = m_lower; while (low) { low >>= 1; out++; } } return out; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::string uint128_t::str(uint8_t base, const unsigned int &len) const { if ((base < 2) || (base > 16)) { throw std::invalid_argument("Base must be in the range [2, 16]"); } std::string out = ""; if (!(*this)) { out = std::string("0"); } else { std::pair<uint128_t, uint128_t> qr(*this, uint128_0); do { qr = divmod(qr.first, base); out = "0123456789abcdef"[(uint8_t)qr.second] + out; } while (qr.first); } if (out.size() < len) { out = std::string(len - out.size(), '0') + out; } return out; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::ostream &operator<<(std::ostream &stream, const uint128_t &rhs) { if ( stream.flags() & stream.oct ) { stream << rhs.str(8); } else if ( stream.flags() & stream.dec ) { stream << rhs.str(10); } else if ( stream.flags() & stream.hex ) { stream << rhs.str(16); } return stream; } // ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
c++ source #2
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 14.1.0
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 14.1.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF gcc 13.1.0
BPF gcc 13.2.0
BPF gcc 13.3.0
BPF gcc trunk
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
FRC 2019
FRC 2020
FRC 2023
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 14.1.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 14.1.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.3
x86 nvc++ 24.5
x86-64 Zapcc 190308
x86-64 clang (amd-stg-open)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (dascandy contracts)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2996)
x86-64 clang (experimental P3068)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (experimental pattern matching)
x86-64 clang (old concepts branch)
x86-64 clang (reflection)
x86-64 clang (resugar)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.4
x86-64 gcc 10.5
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 11.4
x86-64 gcc 12.1
x86-64 gcc 12.2
x86-64 gcc 12.3
x86-64 gcc 13.1
x86-64 gcc 13.2
x86-64 gcc 13.3
x86-64 gcc 14.1
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx (latest)
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
/** * @file uint128_t.hxx * @author your name (you@domain.com) * @version 0.1 * @date 2022-07-23 * @copyright Copyright (c) 2022 * @details An unsigned 128 bit integer type for C++ */ #ifndef _UINT128_T_HXX #define _UINT128_T_HXX #include <cstdint> #include <ostream> #include <stdexcept> #include <string> #include <type_traits> #include <utility> #include <concepts> // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- class uint128_t; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Give uint128_t type traits namespace std { // This is probably not a good idea // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <> struct is_arithmetic<uint128_t> : std::true_type {}; // ---------------------------------------------------------------------------- template <> struct is_integral<uint128_t> : std::true_type {}; // ---------------------------------------------------------------------------- template <> struct is_unsigned<uint128_t> : std::true_type {}; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- }; // namespace std // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // /** **/ // class uint128_t { private: uint64_t m_upper, m_lower; public: // ---------------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t(); // ---------------------------------------------------------------------------- uint128_t(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t(uint128_t &&rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t(const T &rhs); // ---------------------------------------------------------------------------- template <std::integral S, std::integral T> uint128_t(const S &upper_rhs, const T &lower_rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // RHS input args only // Assignment Operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t &operator=(const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t &operator=(uint128_t &&rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Typecast Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- operator bool() const; // ---------------------------------------------------------------------------- operator uint8_t() const; // ---------------------------------------------------------------------------- operator uint16_t() const; // ---------------------------------------------------------------------------- operator uint32_t() const; // ---------------------------------------------------------------------------- operator uint64_t() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitwise Operators // ---------------------------------------------------------------------------- uint128_t operator&(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator&(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator&=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator&=(const T &rhs); // ---------------------------------------------------------------------------- uint128_t operator|(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator|(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator|=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator|=(const T &rhs); // ---------------------------------------------------------------------------- uint128_t operator^(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator^(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator^=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator^=(const T &rhs); // ---------------------------------------------------------------------------- uint128_t operator~() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bit Shift Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t operator<<(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator<<(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator<<=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator<<=(const T &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator>>(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator>>=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator>>=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Logical Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool operator!() const; // ---------------------------------------------------------------------------- bool operator&&(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- bool operator||(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator&&(const T &rhs); // ---------------------------------------------------------------------------- template <std::integral T> bool operator||(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Comparison Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- bool operator==(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator==(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator!=(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator!=(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator>(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator>(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator<(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator<(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator>=(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator>=(const T &rhs) const; // ---------------------------------------------------------------------------- bool operator<=(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> bool operator<=(const T &rhs) const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Arithmetic Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t operator+(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator+(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator+=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator+=(const T &rhs); // ---------------------------------------------------------------------------- uint128_t operator-(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator-(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator-=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator-=(const T &rhs); // ---------------------------------------------------------------------------- uint128_t operator*(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator*(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator*=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator*=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- private: // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::pair<uint128_t, uint128_t> divmod(const uint128_t &lhs, const uint128_t &rhs) const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- public: // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t operator/(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator/(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator/=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator/=(const T &rhs); // ---------------------------------------------------------------------------- uint128_t operator%(const uint128_t &rhs) const; // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator%(const T &rhs) const; // ---------------------------------------------------------------------------- uint128_t &operator%=(const uint128_t &rhs); // ---------------------------------------------------------------------------- template <std::integral T> uint128_t &operator%=(const T &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Increment Operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t &operator++(); // ---------------------------------------------------------------------------- uint128_t operator++(int); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Decrement Operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t &operator--(); // ---------------------------------------------------------------------------- uint128_t operator--(int); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Nothing done since promotion doesn't work here uint128_t operator+() const; // ---------------------------------------------------------------------------- // two's complement uint128_t operator-() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Get private values // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- const uint64_t &upper() const; // ---------------------------------------------------------------------------- const uint64_t &lower() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Get bitsize of value // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint8_t bits() const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Get string representation of value // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::string str(uint8_t base = 10, const unsigned int &len = 0) const; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- }; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // useful values extern const uint128_t uint128_0; extern const uint128_t uint128_1; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // constructors // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint128_t::uint128_t(const T &rhs) : m_upper(0) , m_lower(rhs) {} // ---------------------------------------------------------------------------- template <std::integral S, std::integral T> uint128_t::uint128_t(const S &up_rhs, const T &lo_rhs) : m_upper(up_rhs) , m_lower(lo_rhs) {} // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // assignments operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator=(const T &rhs) { m_upper = 0; m_lower = rhs; return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitwise member operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator&(const T &rhs) const { return uint128_t(0, m_lower & (uint64_t)rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator&=(const T &rhs) { m_upper = 0; m_lower &= rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator|(const T &rhs) const { return uint128_t( m_upper, ( m_lower | (uint64_t)rhs ) ); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator|=(const T &rhs) { m_lower |= (uint64_t)rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator^(const T &rhs) const { return uint128_t( m_upper, ( m_lower ^ (uint64_t)rhs ) ); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator^=(const T &rhs) { m_lower ^= (uint64_t)rhs; return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bit shift member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator<<(const T &rhs) const { return *this << uint128_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator<<=(const T &rhs) { *this = *this << uint128_t(rhs); return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator>>(const T &rhs) const { return *this >> uint128_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator>>=(const T &rhs) { *this = *this >> uint128_t(rhs); return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // LOgical member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator&&(const T &rhs) { return static_cast<bool>(*this && rhs); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator||(const T &rhs) { return static_cast<bool>(*this || rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // comparaison member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator==(const T &rhs) const { return ( !m_upper && ( m_lower == (uint64_t)rhs ) ); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator!=(const T &rhs) const { return ( m_upper | ( m_lower != (uint64_t)rhs ) ); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator>(const T &rhs) const { return ( m_upper || ( m_lower > (uint64_t)rhs ) ); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator<(const T &rhs) const { return ( !m_upper ) ? ( m_lower < (uint64_t)rhs ) : false; } // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator>=(const T &rhs) const { return ( ( *this > rhs ) | ( *this == rhs ) ); } // ---------------------------------------------------------------------------- template <std::integral T> bool uint128_t::operator<=(const T &rhs) const { return ( ( *this < rhs ) | ( *this == rhs ) ); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // arithmetic member operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator+(const T &rhs) const { return uint128_t( m_upper + ( ( m_lower + (uint64_t)rhs ) < m_lower ), ( m_lower + (uint64_t)rhs ) ); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator+=(const T &rhs) { m_upper = m_upper + ( ( m_lower + rhs ) < m_lower ); m_lower = m_lower + rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator-(const T &rhs) const { return uint128_t((uint64_t)(m_upper - ((m_lower - rhs) > m_lower)), (uint64_t)(m_lower - rhs)); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator-=(const T &rhs) { *this = *this - rhs; return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator*(const T &rhs) const { return *this * uint128_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator*=(const T &rhs) { *this = *this * uint128_t(rhs); return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator/(const T &rhs) const { return *this / uint128_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator/=(const T &rhs) { *this = *this / uint128_t(rhs); return *this; } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t uint128_t::operator%(const T &rhs) const { return *this % uint128_t(rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t& uint128_t::operator%=(const T &rhs) { *this = *this % uint128_t(rhs); return *this; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // lhs type T as first arguemnt // If the output is not a bool, casts to type T // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitwise Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator&(const T &lhs, const uint128_t &rhs) { return rhs & lhs; } // ---------------------------------------------------------------------------- template <std::integral T> T &operator&=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(rhs & lhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator|(const T &lhs, const uint128_t &rhs) { return rhs | lhs; } // ---------------------------------------------------------------------------- template <std::integral T> T &operator|=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(rhs | lhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator^(const T &lhs, const uint128_t &rhs) { return rhs ^ lhs; } // ---------------------------------------------------------------------------- template <std::integral T> T &operator^=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(rhs ^ lhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Bitshift operators // ---------------------------------------------------------------------------- uint128_t operator<<(const uint64_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const uint32_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const uint16_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const uint8_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const int16_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const int32_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const int64_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const int8_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator<<(const bool &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> T &operator<<=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(uint128_t(lhs) << rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- uint128_t operator>>(const uint16_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const uint32_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const uint64_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const int16_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const int32_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const int64_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const uint8_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const int8_t &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- uint128_t operator>>(const bool &lhs, const uint128_t &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> T &operator>>=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(uint128_t(lhs) >> rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Comparison Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> bool operator==(const T &lhs, const uint128_t &rhs) { return (!rhs.upper() && ((uint64_t)lhs == rhs.lower())); } // ---------------------------------------------------------------------------- template <std::integral T> bool operator!=(const T &lhs, const uint128_t &rhs) { return (rhs.upper() | ((uint64_t)lhs != rhs.lower())); } // ---------------------------------------------------------------------------- template <std::integral T> bool operator>(const T &lhs, const uint128_t &rhs) { return (!rhs.upper()) && ((uint64_t)lhs > rhs.lower()); } // ---------------------------------------------------------------------------- template <std::integral T> bool operator<(const T &lhs, const uint128_t &rhs) { if (rhs.upper()) { return true; } return ((uint64_t)lhs < rhs.lower()); } // ---------------------------------------------------------------------------- template <std::integral T> bool operator>=(const T &lhs, const uint128_t &rhs) { if (rhs.upper()) { return false; } return ((uint64_t)lhs >= rhs.lower()); } // ---------------------------------------------------------------------------- template <std::integral T> bool operator<=(const T &lhs, const uint128_t &rhs) { if (rhs.upper()) { return true; } return ((uint64_t)lhs <= rhs.lower()); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Arithmetic Operators // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator+(const T &lhs, const uint128_t &rhs) { return rhs + lhs; } // ---------------------------------------------------------------------------- template <std::integral T> T &operator+=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(rhs + lhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator-(const T &lhs, const uint128_t &rhs) { return -(rhs - lhs); } // ---------------------------------------------------------------------------- template <std::integral T> T &operator-=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(-(rhs - lhs)); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator*(const T &lhs, const uint128_t &rhs) { return rhs * lhs; } // ---------------------------------------------------------------------------- template <std::integral T> T &operator*=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(rhs * lhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator/(const T &lhs, const uint128_t &rhs) { return uint128_t(lhs) / rhs; } // ---------------------------------------------------------------------------- template <std::integral T> T &operator/=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(uint128_t(lhs) / rhs); } // ---------------------------------------------------------------------------- template <std::integral T> uint128_t operator%(const T &lhs, const uint128_t &rhs) { return uint128_t(lhs) % rhs; } // ---------------------------------------------------------------------------- template <std::integral T> T &operator%=(T &lhs, const uint128_t &rhs) { return lhs = static_cast<T>(uint128_t(lhs) % rhs); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // IO Operator // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- std::ostream &operator<<(std::ostream &stream, const uint128_t &rhs); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #endif
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree