Golang type conversion

package main

import (
    "fmt"
)

const (
    c uint64 = 112
    d uint64 = 2147483650111
)

func main() {

    var e uint64 = 2147483650111
    fmt.Println(byte(c), byte(d), byte(e))

}

ask everyone why the constant d returns an error constant 2147483650111 overflows byte when converting to byte . While the variable e is intercepted

Dec.17,2021

go has different conversion rules for constants and nonconstants, see https://golang.org/ref/spec-sharpC..

x-> T, simply translate:
A constant value x can be converted to type T if x is representable by a value of T.
constant conversion must require x to be represented by a value of type T. Here T=byte (0-255) obviously cannot express 2147483650111

.

A non-constant value x can be converted to type T in any of these cases:
x is assignable to T.
non-constant conversion only needs to be able to assign x to T type. Here, it can be assigned after truncation, which conforms to the conversion rules

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3df90-2bc22.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3df90-2bc22.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?