Re: Another question about big floating point



mike3 said:

<snip>

Carry on the addition is fairly easy even without a 64-bit type[...],
you just check to see if the sum of the digits is less than either. If
that is so, then it overflowed and hence there is a carry.

Then be sure you use unsigned integers, which are guaranteed to wrap
predictably. (You have no use for the sign bit anyway, since you're
doing sign and magnitude.)

But multiplication is more of a pain, since a simple x * y in N bits
will tell you *whether* a carry occurred, but not *how big* a carry
(unless you're using base 2). For that, you really need 2N bits.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: Any progress yet? (was Re: Fast pi program?)
    ... mike3 wrote: ... snip ... ... you need to compute 2x the digits then convert to 26 (since the ... Chuck F ...
    (comp.programming)
  • every number has its own significance.....
    ... 18 is the only number that is twice the sum of its digits. ... 21 is the smallest number of distinct squares needed to tile a square. ... 26 is the only number to be directly between a square and a cube. ... 27 is the largest number that is the sum of the digits of its cube. ...
    (sci.crypt)
  • Re: 3 value logic. Why is SQL so special?
    ... reasonably intelligent people why their queries returned the wrong answer? ... an example where missing information was involved. ... semantics for SUM. ...
    (comp.databases.theory)
  • Re: six six seven
    ... It is also equal to the sum of its digits plus the cubes of its digits: ... 16661 is the first beastly palindromic prime, ... (Also, note that from the two powers, 47 and 51, we get ...
    (alt.sports.football.pro.ne-patriots)
  • [SUMMARY] Checking Credit Cards (#122)
    ... to see how people approached the Luhn algorithm implementation. ... # check specified conditions to determine the type of card ... # sum the resulting digits, mod with ten, check against 0 ... simple sum of the digits and the final modulo test to determine validity. ...
    (comp.lang.ruby)