- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我需要知道 golang 中 float64 和 complex128 变量类型的最大值。 go 似乎没有 float.h 的等价物,我不知道如何计算它。
最佳答案
例如,
package main
import (
"fmt"
"math"
)
func main() {
const f = math.MaxFloat64
fmt.Printf("%[1]T %[1]v\n", f)
const c = complex(math.MaxFloat64, math.MaxFloat64)
fmt.Printf("%[1]T %[1]v\n", c)
}
输出:
float64 1.7976931348623157e+308
complex128 (1.7976931348623157e+308+1.7976931348623157e+308i)
import "math"
Floating-point limit values. Max is the largest finite value representable by the type. SmallestNonzero is the smallest positive, non-zero value representable by the type.
const (
MaxFloat32 = 3.40282346638528859811704183484516925440e+38 // 2**127 * (2**24 - 1) / 2**23
SmallestNonzeroFloat32 = 1.401298464324817070923729583289916131280e-45 // 1 / 2**(127 - 1 + 23)
MaxFloat64 = 1.797693134862315708145274237317043567981e+308 // 2**1023 * (2**53 - 1) / 2**52
SmallestNonzeroFloat64 = 4.940656458412465441765687928682213723651e-324 // 1 / 2**(1023 - 1 + 52)
)
The Go Programming Language Specification
A numeric type represents sets of integer or floating-point values. The predeclared architecture-independent numeric types are:
uint8 the set of all unsigned 8-bit integers (0 to 255)
uint16 the set of all unsigned 16-bit integers (0 to 65535)
uint32 the set of all unsigned 32-bit integers (0 to 4294967295)
uint64 the set of all unsigned 64-bit integers (0 to 18446744073709551615)
int8 the set of all signed 8-bit integers (-128 to 127)
int16 the set of all signed 16-bit integers (-32768 to 32767)
int32 the set of all signed 32-bit integers (-2147483648 to 2147483647)
int64 the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807)
float32 the set of all IEEE-754 32-bit floating-point numbers
float64 the set of all IEEE-754 64-bit floating-point numbers
complex64 the set of all complex numbers with float32 real and imaginary parts
complex128 the set of all complex numbers with float64 real and imaginary parts
byte alias for uint8
rune alias for int32The value of an n-bit integer is n bits wide and represented using two's complement arithmetic.
There is also a set of predeclared numeric types with implementation-specific sizes:
uint either 32 or 64 bits
int same size as uint
uintptr an unsigned integer large enough to store the uninterpreted bits of a pointer valueTo avoid portability issues all numeric types are distinct except byte, which is an alias for uint8, and rune, which is an alias for int32. Conversions are required when different numeric types are mixed in an expression or assignment. For instance, int32 and int are not the same type even though they may have the same size on a particular architecture.
关于variables - Go中float64和complex128类型的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45105177/
我有一个使用 c++ 的大型代码库标题和许多std::complex对象。但现在我还想使用其他几个使用 fftw 的库( spinsfast 和 ) .不幸的是,混合这两种类型的复合体似乎与 gc
我是 Maxima 的新手,在文档中找不到如何对复数进行正式计算。当我使用未指定的变量时,Maxima 似乎假设它们是真实的: 例如,共轭(x)返回 x。 有没有办法解决这个问题? 提前致谢。 最佳答
我是学习大O表示法的新手,并想到了这个问题。复杂度 O(a * b) 的名称是什么?是线性复杂度吗?多项式?或者是其他东西。实现代码如下。 function twoInputsMult(a, b) {
我是学习大O表示法的新手,并想到了这个问题。复杂度 O(a * b) 的名称是什么?是线性复杂度吗?多项式?或者是其他东西。实现代码如下。 function twoInputsMult(a, b) {
这是我的 Complex 类,我重载了“+” class Complex(object): def __init__(self, real, imag): self.__ima
我正在使用 R5RS 标准的 Scheme 实现。 现在假设您必须找出一个元素 '(2 3 4) 是否在列表 '(1 2 3 4) 中。 至于示例,更严格地说,您希望: 1. (is-in? '(2
注意事项: 我正在使用 Apple LLVM 版本 6.0 (clang-600.0.56)(基于 LLVM 3.5svn)在 OSX 上编译 具体来说,我正在尝试从 LibIIR 编译一个整体源,这
这段fortran代码最初是用Fortran 77格式编写的(我稍后会展示它)。拿到后,我通过转换工具将其转换为f90免费格式。使用intel fortran编译器 ifort,编译和运行和以前一样好
我有一个实现用户定义的算术类型的MyType类。此类提供以下转换运算符 struct MyType { ... operator double() { return to_double
我目前正在使用 Cxx 来允许 Julia 代码与 C++ 库交互。我想做的一部分是在两个方向上有效地传递复杂数据的集合(通常是 vector )。也就是说,我想要以下内容: cv = [1 + 2i
假设我有一个名为“汽车”的实体。 我使用复杂类型来定义“引擎”部分。 [TableName("T_CAR")] public sealed class Car:IEngine { ... pu
我想使用 static_cast 将 complex 转换为 complex 。 Convert complex to complex 我正在尝试做与这篇文章相同的事情,但我需要使用 static_c
` ?
对于多项式方程求解器,最好将其模板化为任何可用类型: template class PolynomialEquation { public: private: array myEquatio
为了在 cython 中将实部与复部分开,我通常使用 complex.real 和 complex.imag 来完成这项工作。然而,这确实会在 html 输出中生成颜色为“python red”的代码
我的问题很简单: Are both "complex float" and "float complex" valid C? 两者似乎都被 gcc 接受而没有警告。 最佳答案 complex 是 co
以下声明有什么区别? 结构体 *ptr1=(结构体*)malloc(4*sizeof(结构体)); 结构体 (*ptr1)[4]=(结构体*)malloc(sizeof(结构体)); 哪个更好用? 最
我想创建一个 C++ 类的复数。这里是Complex.h(最基本的形式) #ifndef _COMPLEX #define _COMPLEX #include "TVector2.h" class C
我已经使用 Visual Studio 2012 和 NDepend 对我的解决方案进行了代码分析 对于方法 MethodA,Visual Studio 显示复杂度为 105,Ndepend 显示为
我的代码: #include using std::cin; using std::cout; using std::istream; using std::ostream; template cl
我在 swift3 中有以下代码,我正在使用 swift lint 对代码进行 linting。给出代码如下: func selectedMenuInLoggedOutState(sender
我是一名优秀的程序员,十分优秀!