Rounding positive and negative numbers (uses only the contents of the unit 1)

Here is the code to round positive and negative numbers (at least seems to work :).

It uses only the contents of the unit 1.

x=-9999.5

y=str(x).find("-")

result = str(x - .50-y)

dot = result.find(".")

final_result = result[:dot]

print final_result

asked 29 Feb '12, 19:21

Cesar%20Nicoleit's gravatar image

Cesar Nicoleit
9926
accept rate: 0%

edited 29 Feb '12, 20:42


One Answer:

Nicely done. Thanks for sharing.

link

answered 29 Feb '12, 19:55

fnenu-1's gravatar image

fnenu-1 ♦♦
18.5k1981231

Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,313
×1,718
×161
×108
×97

Asked: 29 Feb '12, 19:21

Seen: 251 times

Last updated: 29 Feb '12, 20:42