[Tutor] conversion to a fixed_no

Jimmy verma jim_938 at hotmail.com
Tue Oct 7 15:22:52 EDT 2003


I am intending to give the input in the form of a floating point no.  So if 
u are considering

L, R to be

12.099994020394 sthing like this.

L be given the value 12 and R be given the value towards the right of 
decimal point.

I hope i am interpreting L,R rightly.

Can you please elaborate a bit more about your suggestion.

Also what will this code do?? just for the sake of discussing further:

def fix_num(input):
	   # To convert a no into a fixed one.
	   val=input*16*(1<<16)
	   return val

Thanks a lot for discussing my problem.

With best regards,

J+



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

_________________________________________________________________
Buy now! Receive a gold coin on Dhan Teras. 
http://server1.msn.co.in/features/general/dhanteras/index.asp Celebrate 
prosperity!




More information about the Tutor mailing list