Skip to content

Instantly share code, notes, and snippets.

Avatar

Silviu Tantos razius

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

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

You can’t perform that action at this time.