Skip to content

Pow(Inf, -1) == 0 not Inf. True for all negative exponents #36

@vsivsi

Description

@vsivsi

Hi again, this one is more of an edge case... But for consistency with math.Pow()

Also, for -Inf: Pow(-Inf, -1) == -0, but this also doesn't work because of #35

Thanks again!

package main

import (
	"fmt"
        "math"
	"math/big"

	"github.com/ALTree/bigfloat"
)

func main() {
	// Exponentiation of Inf^n equals 0 for all negative n
	// e.g. Inf^-2 = 0

	zero := math.Pow(math.Inf(1), -2)
        fmt.Printf("%f\n", zero)     //   0.000000

	bigneg2 := big.NewFloat(-2)
	bigInf := big.NewFloat(0.0).SetInf(false)
	bigzero := bigfloat.Pow(bigInf, bigneg2)   
	fmt.Printf("%f\n", bigzero)  //   +Inf  !=  0.000000
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions