Porting of libBF library of Fabrice Bellard to the V programming language (vlang)
The libBF is state-free. To ease the use of this module, we have used some static variable to represent the state. Each function of the original library have several arguments to indicate the precision, rounding and flags. Most of the functions have dual-aspect. One do not take a MathContext structure argument and use default arguments, the other have a last argument for the MathContext.
The suffix for the V types of numerical have been renamed according to the V names. The endings in _ui _si and _d are _u64 _i64 and _f64.
The conversion routines begin with from_ and the output routines are member functions: .i64() .u64() .f64() and .str(). This last routine get a 10-base representation. For the original bf_ftoa() there is .str_base(base int). The other names have not been changed.
The operators + - * / % have been overloaded.
The imports are:
The Bigfloats are available through a distinct module. See the
The libbf is part of the distribution and has been patched.
Locate your vmodules directory with
Create a libbf directory in your vmodules directory and copy in it the big directory which contains the libbf library and the interface files.
At the first run of V, the libbf library get compiled for your system. It is possible that the default C-compiler of V reports a bug. In this case compile it with the argument
The /your/path/to_vmodules/library/libbf/big/libbf.o file has not been found. Compilation of the /your/path/to_vmodules/library/cache/xxxxxx/xxxxx.o
cp /your/path/to_vmodules/library/cache/xxx/xx.o /your/path/to_vmodules/library/libbf/big/libbf.o
Thus you can use the next times the default compiler.
LibBF is under the MIT-license
V_gmp is under the
Porting of Decimal part of LibBF