#hi

32 messages · Page 1 of 1 (latest)

sudden musk
#

how can i use sin cos etc with gmpxx varibles ?

sly sage
#

you cant use sin or cos directly with gmpxx

#

it works with integers and rationals not floats

#

if you really need trig just convert the mpf_class to double like this:

#
double d = x.get_d();
double result = sin(d);
#

or go with mpfr if you want actual high precision trig functions

sudden musk
sudden musk
sudden musk
sly sage
#

yeah mpfr gives high precision for floats for big ints use gmp alongside it

inland groveBOT
#

@sly sage has reached level 1. GG!

sly sage
#

mpfr is actually built on gmp so they work well together

#

you won't lose accuracy if you stick to mpfr for all float stuff

sudden musk
inland groveBOT
#

@sudden musk has reached level 3. GG!

sly sage
#

yeah u right exactly double has like 15–17 digits precision max

#

if you need way more use mpfr_class instead of converting to double

#

mpfr_class x("number", number);
mpfr_class y = sin(x);

#

something like that

sudden musk
#

can i convert gmpxx varible ot mpfr varible and return it ?

sly sage
#

yea

sudden musk
#

i need tan (mpq_class *mpf_class )

sly sage
#

you can’t do it directly

#

but

#

you can convert both to mpfr_class then use tan

sudden musk
#

and return tan to gmpxx , its sad how they dont work togther

sly sage
#

yeah fr it sucks they don’t work together

#

but you can return the tan result back to the class

sudden musk
#

is it hard to rewrite a similar library ?

sly sage
#

kinda

#

writing a lib like gmp or mpfr is deep math

#

u need to handle a lot of shi