MCPcopy Index your code
hub / github.com/secdev/scapy / i2h

Method i2h

scapy/fields.py:3393–3402  ·  view source on GitHub ↗
(self, pkt, val)

Source from the content-addressed store, hash-verified

3391 return (ival << self.frac_bits) | fract
3392
3393 def i2h(self, pkt, val):
3394 # type: (Optional[Packet], Optional[int]) -> Optional[EDecimal]
3395 # A bit of trickery to get precise floats
3396 if val is None:
3397 return val
3398 int_part = val >> self.frac_bits
3399 pw = 2.0**self.frac_bits
3400 frac_part = EDecimal(val & (1 << self.frac_bits) - 1)
3401 frac_part /= pw # type: ignore
3402 return int_part + frac_part.normalize(int(math.log10(pw)))
3403
3404 def i2repr(self, pkt, val):
3405 # type: (Optional[Packet], int) -> str

Callers 1

i2reprMethod · 0.95

Calls 2

normalizeMethod · 0.95
EDecimalClass · 0.90

Tested by

no test coverage detected