How to convert float to sortable integer in Python

shellon zhouchengly at gmail.com
Wed Jan 17 01:36:55 EST 2007


I'm sorry I mistake the function name, the function is
floatToRawIntBits(), it convert ieee 754 floating point number to
integer,  e.g. if f1>f2 then floatToRawBits(f1) > floatToRawBits(f1)
I want convert floating point number to sortable string to index in
Lucene, so I want first to conver the floating point number to integer
first, and than convert the integer to sortable string?

so How to convert a ieee 754 floating point to raw bits like the java
api floatToRawBits do?

Appreciate your help!

Steven D'Aprano wrote:

> On Tue, 16 Jan 2007 01:21:52 -0800, shellon wrote:
>
> > Hi all:
> >     I want to convert the float number to sortable integer, like the
> > function float2rawInt() in java, but I don't know the internal
> > expression of float, appreciate your help!
>
> Google says:
>
> Your search - float2rawInt - did not match any documents.
>
> Are you sure about that function? What's a sortable integer?
> 
> 
> -- 
> Steven.




More information about the Python-list mailing list