Home python python. Rounding fractions intentionally up and down

python. Rounding fractions intentionally up and down




From these numbers you need to get x less than there is and y more than it is.

x = 0.001 or x = 0.0015
Y = 0.0025

numbers may be different, i.e. Fixed Round (x, 4) is not suitable, because they can be 0.0001514 and then I will get x = 0.0002, which will be more initial number.

thought to the part of Fraction or bitwise operations, but somehow I do not quite understand how it can be realized. Maybe someone did this.

Answer 1, Authority 100%

Number – number

precision – signs in fractional part


import math


math.floor (Number * 10 ** Precision) / 10 ** Precision


- math.floor (- Number * 10 ** Precision) / 10 ** Precision

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions