Programming · Flashcard

What is the difference between an integer and a real number in Go?

  • AIntegers are whole numbers, real numbers (floating-point) have fractional parts — Go won't mix them without explicit conversion
  • BIntegers are stored on the heap while real numbers are placed on the stack for faster access
  • CReal numbers can only be declared with const, because their precision must be fixed at compile time
  • DThere is no difference — Go converts between integers and floats automatically whenever needed

Why this is the answer

Go is strictly typed: operations between int and float64 require explicit conversion, e.g. float64(age). There is no implicit numeric conversion.

Official docs
Study in Gnoseed →