[Tutor] conversion to a fixed_no

Bob Gailer bgailer at alum.rpi.edu
Mon Oct 6 17:18:00 EDT 2003


At 02:27 AM 10/6/2003, james roy wrote:

>Hello,
>
>I am new to python and is having some problem while writing some module in 
>python. Actually i am writing a code in which i am needed to convert a no. 
>into a fixed_no where the fixed_no's specification is like this:
>
>
>fixed_no is a 32-bit representation of a binary fraction. A fixed_no is a 
>signed quantity, with the two's complement of the entire word used to 
>represent negation. Of the 32 bits in a fixed_no, exactily 12 are to the 
>left of the binary point; thus the largest fixed_no value is 2048-2^(-20), 
>and the smallest is -2048.
>
>Can someone suggest me sthing regarding writing a module to convert a 
>no.into a fixed_no according to the way i have written above.

In what form is the input to this process?

For the sake of discussion I will assume you start with 2 integers (L,R), 
one representing the part to the left and the other the part to the right. 
Ignoring sign for now, the desired result is L<<12 + R.

How will you express the sign? Will either L or R be negative or is there a 
third parameter to indicate the sign?

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003


More information about the Tutor mailing list