Skip to content

math/big: cannot calculate log16 of a 256 bit integer  #28300

@thisismohitgupta

Description

@thisismohitgupta

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

how it works in python...

import math 
a = 0xc6d86e5a2cb4bc532361c2d4940f0b1a0138066e25d65c1c530d080b11f8ca24
a>>89940344608680314083397671686667731393131665861770496634981932531495305005604L
math.log(a)/math.log(16.0)

63.908875905794794

What did you see instead?

does not work for Big Ints

s := "c6d86e5a2cb4bc532361c2d4940f0b1a0138066e25d65c1c530d080b11f8ca24" // Hex value
i := new(big.Int)
i.SetString(s, 16)
// how to get the log with base 16 for a math/big Int variable.

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