Skip to content

Feature request: toBiggestInt #34

@ghost

Description

I need to convert BigInt to float64 and I'm not sure I'm qualified to implement it.

I'm using this:

proc toBiggestFloat(a: BigInt): BiggestFloat =
  for i in countdown(a.limbs.high, 0):
    result = result * BiggestFloat(1 shl 32) + a.limbs[i].BiggestFloat
  if Negative in a.flags:
    result = - result

But it gives me different results from a Haskell implementation as it get close to saturating the float at 179769313486231560835325876058105298516207002341652166261661174625869553267292326574530099287946549246750631490335877017522087105926987962906277604735569213290190919152394180476217125334960946356387261286640198029037799514183602981511756283727771403830521483963923935633133642802139091669457927874464075218945.

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