Skip to content

math/big: SetBytes allows arbitrary numbers of leading zeros  #12751

@hillar

Description

@hillar
package main

import (
    "fmt"
    "math/big"
)

func main() {

    tmp := new(big.Int)

    b := []byte{0x80}
    fmt.Println("%b",b)
    tmp.SetBytes(b)
    fmt.Println("%+d",tmp)

    b00 := []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80}
    fmt.Println("%b",b00)
    tmp.SetBytes(b00)
    fmt.Println("%+d",tmp)

}
%b [128]
%+d 128
%b [0 0 0 0 0 0 0 0 0 0 0 0 128]
%+d 128

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions