1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:20:11 -07:00
go/test/fixedbugs/issue11371.go
Ian Lance Taylor 412dc2f4d3 test: adjust issue11371 to fit in required precision
The language spec only requires that floating point values be
represented with 256 bits, which is about 1e75. The issue11371 test
was assuming that the compiler could represent 1e100. Adjusting the
test so that it only assumes 256 bits of precision still keeps the
test valid, and permits it to pass when using the gofrontend.

Change-Id: I9d1006e9adc9438277f4b8002488c912e5d61cc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/278116
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-15 20:50:35 +00:00

18 lines
784 B
Go

// errorcheck
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Issue 11371 (cmd/compile: meaningless error message "truncated to
// integer")
package issue11371
const a int = 1.1 // ERROR "constant 1.1 truncated to integer|floating-point constant truncated to integer"
const b int = 1e20 // ERROR "overflows int|integer constant overflow"
const c int = 1 + 1e-70 // ERROR "constant truncated to integer"
const d int = 1 - 1e-70 // ERROR "constant truncated to integer"
const e int = 1.00000001 // ERROR "constant truncated to integer"
const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer|floating-point constant truncated to integer"