Best search algorithm to find condition within a range

Steven D'Aprano steve+comp.lang.python at
Wed Apr 8 00:51:50 CEST 2015

On Wed, 8 Apr 2015 01:43 am, jonas.thornvall at wrote:

> No that is not what i am saying, i am saying if you do operations on two
> integers the machine will assume base 10.

We understand what you are saying. You are simply WRONG.

There hasn't been a machine in common use that used other than binary for
integers for probably forty years now, and there has *never* been a PC that
has used other than binary for integers. When you write 12345 as an integer
in a programming language, it is NOT stored internally as five decimal
digits 1 2 3 4 5 in *nearly all languages*. There might be one or two
exceptions, e.g. Hypertalk would store it as a string of bytes 0x3132333435
in hexadecimal, or in binary 0011000100110010001100110011010000110101.

(As you can guess, Hypertalk is not the most efficient of languages.)

But most languages will store the decimal int 12345 in binary:

0011000000111001  # 16 bit word size

00000000000000000011000000111001  # 32 bit word size

(Ignoring Big Endian/Little Endian issues -- some machines store the bytes
the other way around.)

The fact is computer languages automatically convert source code from
(usually) decimal base to whatever their internal storage format uses,
which is normally base 2. They don't work in decimal, using the same
decimal routines you learned in school.


More information about the Python-list mailing list