Skip to content

math.Mod seems to produce wrong output #34756

@burdiyan

Description

@burdiyan

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Printf("%.8f", math.Mod(10, 0.1))
}

https://play.golang.org/p/s725Z6unzo1

What did you expect to see?

I expect 10 % 0.1 to return 0, which is the result I get calculating modulo in a spreadsheet.

What did you see instead?

I see 0.1.

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