How to convert float to sortable integer in Python

I

ireyes

DEAR SIR,
I SAW YOUR INTERNET QUESTION AND I HAVE THE SAME TROUBLE.
CUOLD YOU HELP ME TO MAKE A FLOAT TO INTEGER CONVERTION?
DO YOU HAVE ANY EXEL FILE THAT CAN DO THAT?
REGARDS AND THANKS A LOT

IVAN REYES

___________________________________

AVISO LEGAL: El presente correo electronico no representa la opinion o el consentimiento oficial de la PONTIFICIA UNIVERSIDAD JAVERIANA. Este mensaje es confidencial y puede contener informacion privilegiada la cual no puede ser usada ni divulgada a personas distintas de su destinatario. Esta prohibida la retencion, grabacion, utilizacion, aprovechamiento o divulgacion con cualquier proposito. Si por error recibe este mensaje, por favor destruya su contenido y avise a su remitente.
En este aviso legal se omiten intencionalmente las tildes.

Este mensaje ha sido revisado por un sistema antivirus, por lo que su contenido esta libre de virus.
This e-mail has been scanned by an antivirus system, so its contents is free of viruses.
 
L

Larry Bates

DEAR SIR,
I SAW YOUR INTERNET QUESTION AND I HAVE THE SAME TROUBLE.
CUOLD YOU HELP ME TO MAKE A FLOAT TO INTEGER CONVERTION?
DO YOU HAVE ANY EXEL FILE THAT CAN DO THAT?
REGARDS AND THANKS A LOT

IVAN REYES

___________________________________

AVISO LEGAL: El presente correo electronico no representa la opinion o el consentimiento oficial de la PONTIFICIA UNIVERSIDAD JAVERIANA. Este mensaje es confidencial y puede contener informacion privilegiada la cual no puede ser usada ni divulgada a personas distintas de su destinatario. Esta prohibida la retencion, grabacion, utilizacion, aprovechamiento o divulgacion con cualquier proposito. Si por error recibe este mensaje, por favor destruya su contenido y avise a su remitente.
En este aviso legal se omiten intencionalmente las tildes.

Este mensaje ha sido revisado por un sistema antivirus, por lo que su contenido esta libre de virus.
This e-mail has been scanned by an antivirus system, so its contents is free of viruses.

You have given us an ill defined problem.

1) If you want to convert float to int just use int() function.
s=int(f)

2) If you want to keep some fractional part of the float multiply
it by 10, 100, 1000, 10000, ... depending on how many digits of
precision you wish to retain and then take int().

s=int(f*10000)

would retain 4 digits of precision and throw away the remainder.

3) You can sort on float just fine, so why do you need int()?

-Larry
 
J

John Machin

You have given us an ill defined problem.

1) If you want to convert float to int just use int() function.
s=int(f)

2) If you want to keep some fractional part of the float multiply
it by 10, 100, 1000, 10000, ... depending on how many digits of
precision you wish to retain and then take int().

s=int(f*10000)

would retain 4 digits of precision and throw away the remainder.

3) You can sort on float just fine, so why do you need int()?

and:

(4) Who is the "dear sir" and what was his problem?

(5) How do you imagine that an Excel file could assist?

(6) Please consider giving your CapsLock key a squirt of WD-40 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top