window.ENTITIES={'/api/snippets/python/python%20math.floor()%20rounding%20with%20precision%20down-to%20n%20places':[{"result":true,"message":null,"batch":{"type":"python","name":"python math.floor() rounding with precision down-to n places","items":[{"id":"DkV0g1","type":"python","name":"Python math.floor() rounding with precision down-to n places","content":"import math\n\n\ndef floor_precised(number, precision):\n power = math.pow(10, precision)\n return math.floor(number * power) / power\n\n\nprint(floor_precised(5, 0)) # 5.0\nprint(floor_precised(5.0, 0)) # 5.0\nprint(floor_precised(.5, 0)) # 0.0\n\nprint(floor_precised(1.1234, 0)) # 1.0\nprint(floor_precised(1.1234, 1)) # 1.1\nprint(floor_precised(1.1235, 2)) # 1.12\nprint(floor_precised(1.1235, 3)) # 1.123\n\nprint(floor_precised(-1.1234, 0)) # -2.0\nprint(floor_precised(-1.1234, 1)) # -1.2\nprint(floor_precised(-1.1234, 2)) # -1.13\nprint(floor_precised(-1.1234, 3)) # -1.124\n\nprint(floor_precised(1234, -1)) # 1230.0\nprint(floor_precised(1234, -2)) # 1200.0\nprint(floor_precised(1234, -3)) # 1000.0\n\nprint(floor_precised(5_000.000_001, 0)) # 5000.0\nprint(floor_precised(5_000.000_001, 6)) # 5000.000001\nprint(floor_precised(5_000.000_001, -3)) # 5000.0","source":"https://dirask.com/posts/Python-math-floor-method-example-p5GN01","author":{"id":"Ro41Z0","name":"Faith-W","avatar":"1629030402230__Ro41Z0__w40px_h40px.png","points":503,"role":"BASIC"},"creationTime":1634836184000,"updateTime":null,"removalTime":null}]}}]};