1

When I typed like below

package main

import (
    "fmt"
    "math"
)

func main() {
    fmt.Println(math.MaxInt64*100 > math.MaxInt64+100)
}

and things like math.MaxInt64 + 100 > math.MaxInt64 + 10 and others,

it will output true properly, but how go compares a overflow Int64?

I know the big package provides some operations but is it that?

kocoler
  • 163
  • 8
  • 1
    Please read https://go.dev/blog/constants. Constants do not "overflow" as constant expressions are evaluated with arbitrary precission. – Volker Dec 30 '21 at 12:10
  • @Volker thanks, I will read that post carefully. – kocoler Dec 30 '21 at 12:49
  • 1
    Edit the question to show an example of the overflow you want to detect. The constant expressions in the question does not overflow as noted in the first comment. – Charlie Tumahai Dec 30 '21 at 12:57

0 Answers0