Skip to content

bits_to_name decimal handling seems odd #85

@glennmatthews

Description

@glennmatthews

Environment

  • Python version: 3.9.7
  • netutils version: 1.0.0

Expected Behavior

>>> bits_to_name(1234)
'1Kbps'
>>> bits_to_name(1234, 1)
'1.2Kbps'
>>> bits_to_name(1234, 2)
'1.23Kbps'
>>> bits_to_name(1234, 3)
'1.234Kbps'
>>> bits_to_name(1234, 4)
'1.2340Kbps'

Observed Behavior

>>> bits_to_name(1234)    # expect 0 decimal places, instead get 1 decimal place but it's wrong!
'1.0Kbps'
>>> bits_to_name(1234, 1)
'1.2Kbps'
>>> bits_to_name(1234, 2)
'1.23Kbps'
>>> bits_to_name(1234, 3)
'1.234Kbps'
>>> bits_to_name(1234, 4)  # expect 4 decimal places, instead still get 3 since the fourth is zero
'1.234Kbps'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions