MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / roundToPrec

Function roundToPrec

eos/utils/round.py:4–21  ·  view source on GitHub ↗

nsValue: custom value which should be used to determine normalization shift

(val, prec, nsValue=None)

Source from the content-addressed store, hash-verified

2
3
4def roundToPrec(val, prec, nsValue=None):
5 """
6 nsValue: custom value which should be used to determine normalization shift
7 """
8 # We're not rounding integers anyway
9 # Also make sure that we do not ask to calculate logarithm of zero
10 if int(val) == val:
11 return int(val)
12 roundFactor = int(prec - math.floor(math.log10(abs(val if nsValue is None else nsValue))) - 1)
13 # But we don't want to round integers
14 if roundFactor < 0:
15 roundFactor = 0
16 # Do actual rounding
17 val = round(val, roundFactor)
18 # Make sure numbers with .0 part designating float don't get through
19 if int(val) == val:
20 val = int(val)
21 return val
22
23
24def roundDec(val, prec):

Callers 8

formatAmountFunction · 0.90
nameMethod · 0.90
drawMethod · 0.85
addYMarkMethod · 0.85
getToolTipMethod · 0.85
formatTooltipMethod · 0.85
formatTooltipMethod · 0.85
hasSpoolUpMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected