Best search algorithm to find condition within a range
Albert van der Horst
albert at spenarnc.xs4all.nl
Sat Apr 18 20:08:02 CEST 2015
In article <fd544688-5e9c-418e-9ca9-11b9bcb83186 at googlegroups.com>,
<jonas.thornvall at gmail.com> wrote:
>Den tisdag 7 april 2015 kl. 16:30:15 UTC+2 skrev Denis McMahon:
>> On Tue, 07 Apr 2015 09:29:59 -0400, Dave Angel wrote:
>> > On 04/07/2015 05:44 AM, jonas.thornvall at gmail.com wrote:
>> >> I want todo faster baseconversion for very big bases like base 1 000
>> >> 000, so instead of adding up digits i search it.
>> > How do you know the baseconversion is the bottleneck, if you haven't
>> > written any Python code yet?
>> He doesn't. He doesn't comprehend that as far as a computer is concerned
>> an integer has no specific 'base', it's only when presented in a form for
>> humans to read that it gets base information added in the representation.
>> I suspect he's one of those people that spends his time thinking up
>> elaborate solutions that he has no idea how to implement as a response to
>> dreamt up non existent problems.
>> Denis McMahon, denismfmcmahon at gmail.com
>Bullshit declare two integers in any language one 7 and one 4 and then
>write x=7+4; if you find a programming language where that does not
>yield 11 tell me.
>Integers are internally assumed to be base 10 otherwise you could not
>calculate without giving the base.
>All operations on integers addition, subtraction, multiplication and
>division assume base 10.
Fire up a lowlevel interpreter like Forth. (e.g. gforth)
7 CONSTANT A 4 CONSTANT B
A B + PAD !
PAD now contains the sum of A and B.
Now inspect the actual computer memory:
PAD 100 DUMP
You will see the bytes, represented in base 16, but PAD
just contains 11
In forth you can change the number base. That doesn't affect PAD
but the output is different
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
More information about the Python-list