Go Floating Point: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 10: Line 10:


=Floating-Point Literals=
=Floating-Point Literals=
Decimals:
<syntaxhighlight lang='go'>
var x float = 123.45
</syntaxhighlight>
Scientific notation:
<syntaxhighlight lang='go'>
var x float = 1.23e3
</syntaxhighlight>

Revision as of 04:07, 19 August 2023

Internal

Overview

Floating-point numbers are designated by the following pre-declared type identifiers:

  • Single precision float32 4 bytes IEEE-754 binary floating point, approximately 6 digits of precision.
  • Double precision float64, 15 digits of precision.
  • Complex: complex64 and complex128.

Uninitialized variable value: +0.000000e+000

Floating-Point Literals

Decimals:

var x float = 123.45

Scientific notation:

var x float = 1.23e3