[erlang-questions] bignum sqrt broken in erlang?
Trevor Woollacott
trevorw@REDACTED
Tue Aug 25 15:39:53 CEST 2009
Hi
Erlang does not support arbitrary-precision arithmetic for square root, and
instead it uses the normal C maths library to perform sqrt.
So your math:sqrt(N) is not correct.
Regards,
Trevor
----- Original Message -----
From: "Angel Alvarez" <clist@REDACTED>
To: <erlang-questions@REDACTED>
Sent: Tuesday, August 25, 2009 3:11 PM
Subject: [erlang-questions] bignum sqrt broken in erlang?
> Hi
>
> let ab=N
> let M=(a+1)(b+1);
>
> M=ab+a+b+1 that is N +a +b +1 so M > N
>
> Ok but in erlang...
>
> Erlang R13B01 (erts-5.7.2) [source] [rq:1] [async-threads:0] [hipe]
> [kernel-poll:false]
>
> Eshell V5.7.2 (abort with ^G)
> 1> N=71641520761751435455133616475667090434063332228247871795429.
> 71641520761751435455133616475667090434063332228247871795429
>
> 2> R0=trunc(math:sqrt(N)).
> 267659337146589062070609641472
>
> 3> R1=R0+1.
> 267659337146589062070609641473
>
> 4> M=R1*R1.
> 71641520761751431352030800763682813030352458120945601609729
>
> 5> M -N > 0.
> false
>
> where is the problem? That's erlang or the gmp library?
>
> /Angel
>
>
>
>
>
>
>
> --
> Agua para todo? No, Agua para Todos.
> ->>-----------------------------------------------
> Clist UAH a.k.a Angel
> ---------------------------------[www.uah.es]-<<--
>
> DSpace me recuerda a Ice Age, el bichito que se apega a su castaña y trata
> de llevarla a todos lados.
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
More information about the erlang-questions
mailing list