Questions tagged [multiprecision]
83 questions
2
votes
2 answers
boost serialization of mpfr_float
I would like to serialize a custom class containing an boost::multiprecision::mpfr_float as a member. It says here in the Boost.Serialization documentation that a type T is serializable iff at least one of 5 properties is true, and here at the…

ofloveandhate
- 199
- 1
- 10
2
votes
2 answers
Boost muliprecision cpp_dec_float compare only to desired precision
I am using the boost::multiprecision library for decimal float types, and wish to compare two floats to the specified precision.
However, cpp_dec_float seems to compare the number not to the specified precision, but also includes the guard…

namezero
- 2,203
- 3
- 24
- 37
2
votes
1 answer
Round boost::multiprecision::mpq_rational to the nearest integer
What is the best way to round boost::multiprecision::mpq_rational to the nearest integer?
An ugly solution is:
#include
using namespace boost::multiprecision;
inline int round_to_int(mpq_rational v)
{
mpz_int vf_mpz…

user3605620
- 157
- 9
2
votes
2 answers
How to stop `ast.parse` from converting numerical values into int/floats?
For example::
>>> import ast
>>> print(type(ast.parse('1.2', mode='eval').body.n)
float
How do I let the parser convert a python source file into a syntax tree, while preserving the original values of nodes in str type? Because I need to convert…

koo
- 2,888
- 1
- 23
- 29
1
vote
1 answer
Boost multiprecision cpp_float not working properly when not using cpp_bin_float_(50/100)
I need to do calculations with higher precision than doubles and am using boost::multiprecision for that. This works perfectly fine when I use boost::multiprecision::cpp_bin_float_50 or boost::multiprecision::cpp_bin_float_100. So simply doing…

Paul Aner
- 361
- 1
- 8
1
vote
1 answer
how to check/and convert if a boost::multiprecision::cpp_dec_floa can be "safely" converted to int,double,float?
Question:
I want to check if a boost::multiprecision::cpp_dec_float<100> value can be safely
converted into a float/double or (u)int8,16,32,... without range problems
Background:
The cpp_dec_float is comming from an CSV import (i can't change that -…

llm
- 557
- 3
- 15
1
vote
0 answers
How to express extreme low numbers
How can we correctly calculate the following?
df <- data.frame(logp=c(-2,-200,-600))
10^(df$logp)
# [1] 1e-02 1e-200 0e+00
This will give us 0 in logp=-600. Can we handle this problem?

user224050
- 317
- 3
- 10
1
vote
1 answer
python mpmath nstr strip zeros not
How can I let the python mpmath.nstr function keep all the trailing zeros for mpmath.mpf('0')? It looks that the strip_zeros optional argument does not work for mpmath.mpf('0') as seen in the following example:
Python 3.8.5 (default, Jul 28 2020,…

norio
- 3,652
- 3
- 25
- 33
1
vote
0 answers
Boost Multiprecision bad_lexical_cast Linker error in VS 2019 Community
I am trying to use the Boost Multiprecision library for the ccp_dec_float and am having some serious troubles with trying to run it. I am consistently getting a linker error that says:
Severity Code Description Project File Line …

mcdz89
- 47
- 1
- 8
1
vote
0 answers
How to use Multiprecision Computing Toolbox with normcdf in Matlab
I have the same problem as here https://comp.soft-sys.matlab.narkive.com/HV95Az6b/how-to-compute-the-normal-cumulative-probability-at-extremely-precision
I download the package https://www.advanpix.com/documentation/users-manual/
and know how to use…

Bob
- 217
- 1
- 3
- 9
1
vote
2 answers
hex string arithmetic in c++
I want to do basic arithmetic (addition, subtraction and comparison) with 64 digit hex numbers represented as strings. for example
"ffffa"+"2" == "ffffc"
Since binary representation of such a number requires 256 bits, I cannot convert the string to…

gopy
- 328
- 1
- 9
1
vote
1 answer
In Julia: BigFloat RoundFromZero Seems Strange
In the Julia 1.0.0 REPL I get the following behavior. The first line is an example from the documentation
https://docs.julialang.org/en/v1/base/math/#Base.Rounding.RoundFromZero
julia> BigFloat("1.0000000000000001", 5, RoundFromZero)
1.06
The…

Julia Learner
- 2,754
- 15
- 35
1
vote
1 answer
Boost Interval with Multiprecision
I try to use the boost interval arithmetic library together with the boost multiprecision library. If I use standard double precision with the native double datatype, everything works fine.
With the multiprecision library however, it produces…

SampleTime
- 291
- 3
- 19
1
vote
1 answer
Undefined F1 scores in multiclass classifications when model does not predict one class
I am trying to use F1 scores for model selection in multiclass classification.
I am calculating them class-wise and average over them:
(F1(class1)+F1(class1)+F1(class1))/3 = F1(total)
However, in some cases I get NaN values for the F1 score. Here is…

Coco
- 41
- 3
1
vote
2 answers
Type conversion c++, quadmath
The quadmath library does not have much documentation online and I would like to perform two simple actions using __complex128 type.
Is there a way to easily print the value inside a variable of this type?
How can I convert back a variable from…

NSZ
- 215
- 1
- 7