Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Consider padding left zeros in default hex and binary printout #2106

Open
@rebcabin

Description

@rebcabin

Also, negative notation in hex and binary should not be the default ... it's almost never useful.

What LP prints now:

DECIMAL
-96 -17 80 107

HEX (VERIFIED AGAINST CPYTHON)
-0x60 -0b1100000
-0x11 -0b10001
0x50 0b1010000
0x6b 0b1101011

BITS (VERIFIED AGAINST CPYTHON)
0xa0 0b10100000
0xef 0b11101111
0x50 0b1010000
0x6b 0b1101011

DECIMAL
-42 -99 3 -110

HEX (VERIFIED AGAINST CPYTHON)
-0x2a -0b101010
-0x63 -0b1100011
0x3 0b11
-0x6e -0b1101110

BITS (VERIFIED AGAINST CPYTHON)
0xd6 0b11010110
0x9d 0b10011101
0x3 0b11
0x92 0b10010010

What I would rather see:

DECIMAL
-96 -17 80 107

HEX (VERIFIED AGAINST CPYTHON)
0xa0 0b10100000
0xef 0b11101111
0x50 0b01010000
0x6b 0b01101011

BITS (VERIFIED AGAINST CPYTHON)
0xa0 0b10100000
0xef 0b11101111
0x50 0b01010000
0x6b 0b01101011

DECIMAL
-42 -99 3 -110

HEX (VERIFIED AGAINST CPYTHON)
0xd6 0b11010110
0x9d 0b10011101
0x03 0b00000011
0x92 0b10010010

BITS (VERIFIED AGAINST CPYTHON)
0xd6 0b11010110
0x9d 0b10011101
0x03 0b00000011
0x92 0b10010010

Here is the code that prints:

def print_fully_lp_bhv_small(lphv_small : LpBhvSmall) -> None:
    i : i32
    print("DECIMAL")
    print(lphv_small.a)
    print('')
    print("HEX (VERIFIED AGAINST CPYTHON)")
    for i in range(4):
        elt : i32 = i32(lphv_small.a[i])
        hx : str = hex(elt)
        print(hx, end=' ')
        bn : str = bin(elt)
        print(bn)
    print('')
    print("BITS (VERIFIED AGAINST CPYTHON)")
    for i in range(4):
        elt : i32 = i32(lphv_small.a[i])
        elt &= i32(0xff)
        hx : str = hex(elt)
        print(hx, end=' ')
        bn : str = bin(elt)
        print(bn)
    print('')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions