Search code examples
programming-languagesintegerbit

Programming language with arbitrary but fixed precision integers?


Are there any programming languages out there that support n-bit integer types for arbitrary n as primitives? That is, is there a language where I could write something to the effect of

int[137 bits] n = 0;

Note that this isn't the same as asking if there's a language with arbitrary-precision integers in them. I'm looking specifically for something where I can have fixed-precision integers for any particular fixed precision I'd like.


Solution

  • Verilog would express that as reg [136:0] n. Hardware description languages (HDL) all give you similar capabilities. You can use Verilog as a scripting language as well, but that's not really its design center and won't give you the performance you could get with a BigInt style integer in a regular programming language.