英文:
Why are complex numbers a primitive numeric type in Go?
问题
Go为复数定义了两种数值类型,complex64
和complex128
。这是罕见的。大多数编程语言将复数定义为实部和虚部的组合,而不是为此目的包含特定的原始类型。(即使在群论中,复数也被形式上构造为实数对。)为什么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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论