Re: big numbers

From: Nevzat Guler <nguler_at_jlab.org>
Date: Sun, 10 Jun 2007 19:08:47 -0400 (EDT)

	Hello,
	Related to my previous question: I found that conversion from
unsigned long long to double does not work properly. But when I use long double everything is ok.
So, I think my problem is solved by using long double instead of double.

        Best regards,

                                Nevzat Guler

On Sun, 10 Jun 2007, Roland Kuhn wrote:

> Hi Nevzat!
>
> On 10 Jun 2007, at 14:46, Nevzat Guler wrote:
>
> >
> > Hello,
> > I am trying to divide following some big numbers, Below is the
> > simplified version of what I am doing with actual numbers:
> > long long int a = 6488530998;
> > long long int b = 7409765618;
> > double c = ((double)(a)) / ((double)(b));
> > I print out the numbers but c comes out to be c = 1.7806
> >
> There's something funny going on:
>
> root [1] long long int a = 6000000000LL
> [...]
> root [11] a/1
> (long long)6000000000
> root [12] a/2
> (long long)3000000000
> root [13] a/2.
> (double)5.00000000000000000e-01
> root [14] cout << (double)a << endl
> 1
>
> So, you've probably forgotten the LL suffix (I'm on MacOS X and got
> an error when I tried that), but even with that the conversion from
> long long to double does not work... BTW:
>
> root [18] a=12000000000LL
> (const long long)12000000000
> root [19] cout << (double)a << endl
> 2
>
> Funny, isn't it?
>
> Ciao,
> Roland
>
> --
> TU Muenchen, Physik-Department E18, James-Franck-Str., 85748 Garching
> Telefon 089/289-12575; Telefax 089/289-12570
> --
> CERN office: 892-1-D23 phone: +41 22 7676540 mobile: +41 76 487 4482
> --
> Any society that would give up a little liberty to gain a little
> security will deserve neither and lose both. - Benjamin Franklin
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GS/CS/M/MU d-(++) s:+ a-> C+++ UL++++ P+++ L+++ E(+) W+ !N K- w--- M
> + !V Y+
> PGP++ t+(++) 5 R+ tv-- b+ DI++ e+++>++++ h---- y+++
> ------END GEEK CODE BLOCK------
>
>
>
Received on Mon Jun 11 2007 - 01:16:35 CEST

This archive was generated by hypermail 2.2.0 : Mon Jun 11 2007 - 17:50:01 CEST