# Re: [OT] Re: Long number base conversion

*From*: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxxx>*Date*: Sat, 27 Nov 2010 18:00:23 -0500

On 11/27/2010 3:44 PM, BartC wrote:

"Eric Sosman" <esosman@xxxxxxxxxxxxxxxxxxxx> wrote in message

news:icr452$boe$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

[...]

If you know you want to convert the result to decimal (and perhaps

that you don't want to do much else with it), one thing you can do is

handle the trailing zeroes specially. As you're plowing along building

up 1 * 2 * 3 * ... you can remove all the 2's and 5's from each new

factor and count how many you've removed. Then at the end you'll have

You mean that in 11! * 12, the 12 becomes 6, and I add one to the number

of two's?

Almost. The 12 becomes 3 and you add *two* to the number of twos.

What about *25 which becomes *5, do I apply the rule again to get *1?

Yes. And when you get to *300 you accumulate two twos and two

fives and wind up with *3.

(I've just tried this, and unless I made a mistake (which is quite

likely), I found it difficult to measure the difference on 100000!, and

that's without doing the adjustments at the end.)

I neglected to say so, but I assumed you'd do the "casting out"

of twos and fives in ordinary integer arithmetic, before moving into

the big-number realm. Also, an operation to multiply a big-number by

an ordinary integer (rather than by a big-number whose value happens

to be "small") would probably be worth while.

--

Eric Sosman

esosman@xxxxxxxxxxxxxxxxxxxx

.

**Follow-Ups**:**Re: [OT] Re: Long number base conversion***From:*Mark Wooding

**Re: [OT] Re: Long number base conversion***From:*BartC

**References**:**Re: Long number base conversion***From:*BartC

**Re: Long number base conversion***From:*Mark Wooding

**Re: Long number base conversion***From:*BartC

**Re: Long number base conversion***From:*Eyegor

**Re: Long number base conversion***From:*BartC

**Re: Long number base conversion***From:*Mark Wooding

**Re: Long number base conversion***From:*BartC

**[OT] Re: Long number base conversion***From:*Eric Sosman

**Re: [OT] Re: Long number base conversion***From:*BartC

- Prev by Date:
**Re: design inquiry** - Next by Date:
**Re: [OT] Re: Long number base conversion** - Previous by thread:
**Re: [OT] Re: Long number base conversion** - Next by thread:
**Re: [OT] Re: Long number base conversion** - Index(es):