Skip to content
Advertisement

Tag: floating-point

How to truncate float values?

I want to remove digits from a float to have a fixed number of digits after the dot, like: I need to output as a string to another function, not print. Also I want to ignore the lost digits, not round them. Answer First, the function, for those who just want some copy-and-paste code: This is valid in Python 2.7

Advertisement