Re: Printf problem with big numbers....
- From: Jordan Abel <random832@xxxxxxxxx>
- Date: 24 Jan 2006 03:36:51 GMT
On 2006-01-24, pasukaru@xxxxxxxxx <pasukaru@xxxxxxxxx> wrote:
> I need to work with big integers ( around 2.^64), and I know it is not
> possible to have integer that big.
> So I use "double" instead, and it is ok with calculations.
> But when I want to print them on screen or in a file, there is a
> problem...
>
> For example, if I write this :
>
> printf("result: %lf\n",1234567890987654321.012345678);
>
> What I get on cmd is:
>
> result: 1234567890987654400.000000
try %.0f to get rid of the extra decimal digits
[incidentally, %lf is not needed for printf, and is forbidden in c89]
> Can anybody tell me WHY ?
your doubles aren't precise enough? try long double maybe [though that's
not guaranteed to be better]
.
- Follow-Ups:
- Re: Printf problem with big numbers....
- From: pasukaru@xxxxxxxxx
- Re: Printf problem with big numbers....
- References:
- Printf problem with big numbers....
- From: pasukaru@xxxxxxxxx
- Printf problem with big numbers....
- Prev by Date: Re: c.l.c wiki update
- Next by Date: Re: Printf problem with big numbers....
- Previous by thread: Re: Printf problem with big numbers....
- Next by thread: Re: Printf problem with big numbers....
- Index(es):
Relevant Pages
|