Skip to content

6g: mparith functions truncate instead of rounding when changing precision #931

@griesemer

Description

@griesemer
6g doesn't accept this, gccgo does.

package main

const ten = 100 * 0.1
const fifty = 100 * 0.5

var x int = ten  // this does not work
var y int = fifty  // this works

// 6g test.go
// test.go:6: constant 10 truncated to integer

0.1 cannot be accurately represented in binary form, but this case seems like it should
work. Perhaps there is a rounding bug somewhere or the number of bits used internally
needs to be increased (short of using rationals).

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