The basis of the type of language go

1. Boolean: bool

2. Integer: int8, byte, int16, int, uint, uintptr etc.

3. floating-point type: float32, float64

4. plural types: complex64, complex128

5. String: string

6. character types: rune

7. Error Type error

Go language also supports complex types:

Pointers, arrays, slices, Dictionary, channel Chan, struct structure, the interface interface.

For conventional development with int and uint on it, with no need to explicitly specify the length int8 like, so difficult to transplant

 

  1.Bool type:

    As with other keywords bool, can be assigned to a predefined true and false. But the Boolean type can not accept other types of assignments, does not support automatic or mandatory type conversion. For example var b bool      

                            b = 1 is wrong. Can not be replaced by 0 and 1 with true and false

 

  2. Plastic

 

 Note that int32 and int is not the same type, different types of operation is not in the Go language

Other languages ​​with C

Bit computing:

 

   Floating-point type: float32 equal to C float language, float64 equal to double C language

  Floating-point comparison: Float is not accurate because it is not directly expressed == calculated by

   Recommended: import "math"

    func IsEuqal(f1,f2,float64)bool{

      return math.Fdim(f1,f2)<p

    }

 

Guess you like

Origin www.cnblogs.com/beautiful7/p/12337786.html