I’m glad to present two new registered packages which add more “native-like” types to Julia, mostly implemented in the same way as Base builtin integer and floating point types.
Both packages can lead to segfaults that I don’t understand, and they are under-tested, so they must be considered as experimental; other contributors will be needed to overcome the shortcomings (read the respective READMEs for more information).
That said, they can already be useful ![]()
BitIntegers.jl exports signed and unsiged integer types of size 256, 512 and 1024 bits, but any other size (multiple of 8 bits) can be created easily via a macro.
The main unimplemented features are division operations, for which intrinsics (LLVM builtin) don’t work, at least on my machine. So this is currently done via conversion to/from BigInt, which is very slow.
BitFloats.jl simply wraps two floating-point types exposed by LLVM:
-
Float80is apparently not available on all machines, but it works OK on mine. The outstanding issue is that currently creating arrays of them lead easily to segfaults (this is a bug in julia which should go away reasonably soon) -
Float128is quite slow for most operations: LLVM doesn’t implement those (on my machine), so conversion to/fromBigFloatis done.
Overall I was amazed that these builtin-like types could be implemented in packages, with relatively few lines of codes; but there is a lot of duplication with Base code; I would be happy to contribute to a refactoring effort in order to reduce duplication.
Again, these packages are at a very experimental stage, and could be seen as only a proof of concept; in particular, it’s not clear that BitFloats.jl can ever reach maturity, but it may help in the development of other solutions.
Happy hacking!