Help! INT longer than LONG
Author Message
Help! INT longer than LONG

HI!

I need to do calculations using numbers longer than LONG. They must be
accurate so float won't do. Is there a way of doing this?

/Henrik
_______________________________________________________

Henrik Andoff           +46 (0)13 260974

Thu, 15 Apr 1999 02:00:00 GMT
Help! INT longer than LONG

(a*k + b) * (c*k + d) = (a*c)*k^2 + (a*d + b*c) * k + b*d

.

Quote:
> HI!

> I need to do calculations using numbers longer than LONG. They must be
> accurate so float won't do. Is there a way of doing this?

> /Henrik
> _______________________________________________________

> Henrik Andoff           +46 (0)13 260974

Fri, 16 Apr 1999 03:00:00 GMT
Help! INT longer than LONG

Quote:

>I need to do calculations using numbers longer than LONG. They must be
>accurate so float won't do. Is there a way of doing this?

BCD's, maybe?

J.

Fri, 16 Apr 1999 03:00:00 GMT
Help! INT longer than LONG

Then try double.

Quote:
> HI!

> I need to do calculations using numbers longer than LONG. They must be
> accurate so float won't do. Is there a way of doing this?

Fri, 16 Apr 1999 03:00:00 GMT
Help! INT longer than LONG

Quote:

> I need to do calculations using numbers longer than LONG. They must be
> accurate so float won't do. Is there a way of doing this?

Various multi-precision integer libraries are around.  Try gmp, the
GNU package (version 2 supports integers, rationals and even a
floating-point format) from your local GNU archive.

--

Sat, 17 Apr 1999 03:00:00 GMT
Help! INT longer than LONG

.

Quote:
> HI!

> I need to do calculations using numbers longer than LONG. They must be
> accurate so float won't do. Is there a way of doing this?

> /Henrik

Go ahead and use double.  As long as you restrict yourself to
integer values, you shouldn't have any rounding problems.  Some
implementations support 64-bit longs as "double long" or "long

--
==========================================================================

| Air-Shields Information Systems  | http://www.cerfnet.com/~timb (New!) |
==========================================================================

Sat, 17 Apr 1999 03:00:00 GMT
Help! INT longer than LONG

In article

Quote:

> HI!

> I need to do calculations using numbers longer than LONG. They must be
> accurate so float won't do. Is there a way of doing this?

Since you desire to have numbers with the same ilk as 'long', I assume
that you can use integers.  Given this constraint, sometimes 'double'
numbers may fit the bill.  For whole (integer) numbers, double numbers are
fully accurate.  Using IEEE numbers, they have at least 50 bits of
accuracy, which may be enough in your case.  As long as you don't try to
excede 50 bits of a whole number you should be safe.

The assumption is that long's in your case are 32 bits (which is common,
but not universal).  The increased accuracy is one of the reasons that the
result of 'difftime' (a standard function) is expressed as a 'double'.

The errors in floating point come with numbers that are not exact when
expressed in floating point.  If you stick to integers, they work quite
well.  Most of the time it is a waste, since integer arithmetic is much
quicker.

--
Tom Watson

Sat, 17 Apr 1999 03:00:00 GMT

 Page 1 of 1 [ 7 post ]

Relevant Pages