Skip to content

Instantly share code, notes, and snippets.

View razius's full-sized avatar

Silviu Tantos razius

View GitHub Profile
@razius
razius / rounding_decimals.md
Created January 19, 2016 14:34 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value