为什么复数在Go语言中是一种原始的数值类型?

huangapple go评论66阅读模式
英文:

Why are complex numbers a primitive numeric type in Go?

问题

Go为复数定义了两种数值类型,complex64complex128。这是罕见的。大多数编程语言将复数定义为实部和虚部的组合,而不是为此目的包含特定的原始类型。(即使在群论中,复数也被形式上构造为实数对。)为什么Go的设计者决定Go需要原始类型的复数?

英文:

Go defines two numeric types for complex numbers, complex64 and complex128. This is rare. Most programming languages define complex numbers as the combination of a real and complex part, rather than including a specific primitive for the purpose. (Even in group theory complex numbers are formally constructed as pairs of reals.) Why did the designers of Go decide that Go needed primitive types for complex numbers?

答案1

得分: 8

肯·汤普森(Ken Thompson)是Go语言的主要作者之一,他希望在Go语言中加入复数,因此他将复数添加到了Go语言规范中,并为Go的gc编译器实现了复数功能。

英文:

Ken Thompson, one of the principal Go authors, wanted complex numbers in Go and so he added them to the Go language specification and implemented complex numbers for the Go gc compilers.

答案2

得分: 0

因为它们非常有用?而且:复数就是这样的:一个实部和一个虚部。

英文:

Because they are dead useful? And: Go complex numbers are just that: A real and imaginary part.

huangapple
  • 本文由 发表于 2014年3月3日 08:46:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/22135819.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定