Skip to content

Instantly share code, notes, and snippets.

View Varbaek's full-sized avatar

Hans-Michael Varbaek Varbaek

  • VarBITS
  • Copenhagen, Denmark
View GitHub Profile

Keybase proof

I hereby claim:

  • I am varbaek on github.
  • I am varbits (https://keybase.io/varbits) on keybase.
  • I have a public key whose fingerprint is 3B51 7D0D 7640 C17D A2F2 D1D2 59AB 18B7 6E4D C1CB

To claim this, I am signing this object:

@Varbaek
Varbaek / rounding_decimals.md
Created September 19, 2017 17:31 — 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