[Tutor] First realscript + Game of Life
kent37 at tds.net
Sat Nov 11 20:17:44 CET 2006
Luke Paireepinart wrote:
> Kent Johnson wrote:
>> Luke Paireepinart wrote:
>>> I was trying to make it clear that Python wasn't directly accessing
>>> the binary from memory with this function Carlos had.
>>> The function just mathematically converted a base-10 number into a
>>> base-2 number.
>> No. It converts a binary representation of a number into a string
>> representation of the binary representation of the number. There is no
>> base-10 number involved.
> Binary is base-2.
> Decimal is base-10.
> Integers in python are base-10.
no. Integers are represented in whatever form the C language
implementation uses which on most modern computers is binary.
When integers are printed in Python, the string representation of the
integer is in base-10. The underlying integer is probably not in base 10.
> Python doesn't give him direct access to the bits in memory.
> It gives him a base-10 integer (a decimal number)
> he uses a mathematical conversion to go from a decimal integer to a list
> of binary bits.
no, he uses a mathematical conversion to go from a number represented in
the internal format used by the C implementation (probably binary) to a
list of '0' and '1' characters which represent binary bits.
> Do you disagree?
You have to make a distinction between the bit pattern used to represent
the integer value, which is binary, and the character pattern used to
represent the integer.
> The argument to the function is an integer.
>>> Anyway, I just wanted to make sure that Carlos knew that python
>>> wasn't directly copying the binary representation from memory into a
>>> Python was getting the base-10 integer representation out of the binary,
>> No, there is no base-10 representation anywhere in Carlos' program, at
>> least not on any computer he is likely to be using to run the program.
>>> and then the function converted this back again into base2 using
>>> binary shifts. I.E. the sentence 'copy binary numbers from memory'
>>> made me think Carlos thought the binary was directly copied into a list.
>>> I also clarified that it's not a 'module' it's a function.
>>> Am I still confused, Kent?
>> Yes. Maybe someone else can explain better than me?
More information about the Tutor