float和double精度
文章分类:Java编程
float与double的范围和精度
1 范围
float和double的范围是由指数的位数来决定的。
float的指数位有8位,而double的指数位有11位,分布如下:
float:共32位
1bit(符号位)
8bits(指数位)
23bits(尾数位)
double:共 64位
1bit(符号位)
11bits(指数位)
52bits(尾数位)
于是,float的指数范围为-127~+128,而double的指数范围为-1023~+1024,并且指数位是按补码的形式来划分的。其中负指数决定了浮点数所能表达的绝对值最小的非零数;而正指数决定了浮点数所能表达的绝对值最大的数,也即决定了浮点数的取值范围。
float的范围为-2^128 ~ +2^128,也即-3.40E+38 ~ +3.40E+38;double的范围为-2^1024 ~ +2^1024,也即-1.79E+308 ~ +1.79E+308。
2 精度
float和double的精度是由尾数的位数来决定的。浮点数在内存中是按科学计数法来存储的,其整数部分始终是一个隐含着的“1”,由于它是不变的,故不能对精度造成影响。
float:2^23 = 8388608,一共七位,这意味着最多能有7位有效数字,但绝对能保证的为6位,也即float的精度为6~7位有效数字;
double:2^52 = 4503599627370496,一共16位,同理,double的精度为15~16位。
分享到:
相关推荐
Data types supported: Integer, Long, Float and Double. Handles multiple ports. One instance per port. Event driven. You get an event whenever a transaction has finished. Broadcast (slave ID 0). Enron ...
Byte, Short, Int, Long, Float and Double numeric data types Array and string slicing Flexible 'collection' system for dealing with linked lists etc Low level pointer handling UTF16 strings The ...
Item 60: Avoid float and double if exact answers are required Item 61: Prefer primitive types to boxed primitives Item 62: Avoid strings where other types are more appropriate Item 63: Beware the ...
Code for available locales, separated out other .cpp files that then do not depend on resource bundle code and res_index bundles.
Exercise 2.1: What are ... Between a float and a double? Exercise 2.2: To calculate a mortgage payment, what types would you use for the rate, principal, and payment? Explain why you selected each type.
■ SIMPLE_INTEGER, SIMPLE_FLOAT, and SIMPLE_DOUBLE Data Types ■ CONTINUE Statement ■ Sequences in PL/SQL Expressions ■ Dynamic SQL Enhancements ■ Named and Mixed Notation in PL/SQL Subprogram ...
The new datatypes BINARY_FLOAT and BINARY_DOUBLE can improve performance in number-crunching applications, such as processing scientific data. Native compilation is easier and more integrated, with ...
//select 中通过 float查询的前提是MD都有或者是double double //25-53代表double 但是不可以写精确度 >15位用科学计数法 字符串类型 char varchar text blob enum(v1,v2,v3⋯⋯65535) 插入的值是其中的一个...
详解 Kotlin Reference Basic Types, String, Array and Imports 基本数据类型 Kotlin中支持的基本数据类型及它所占Bit宽度: Type Bit width Double 64 Float 32 Long 64 Int 32 Short 16 Byte 8...
void spbiln(float *d, float *c, long *ln, float *b, float *a, float *work, long *error) #else void spbiln(d, c, ln, b, a, work, error) long *ln, *error; float *d, *c, *b, *a, *work; #endif { /* Local...
如果我们将 float 更改为 double 可能会更快,但蓝图中没有 double 类型 所有公共函数都是 BlueprintCallable,因此它们可以在每个蓝图中使用 来自 DevDad 和 Dedicated to you and Unreal Community。代码现在在 ...
CD <br> A public int add(int a) B public void add(long a) C public void add(int a,int b) D public void add(float a) 12.如果下列的方法能够正常运行,在控制台上将显示什么? ACD <br>...
Java APIs: In addition to Object and APIs related to exceptions, you explore Math, StrictMath, BigDecimal, BigInteger, Package, Boolean, Character, Byte, Short, Integer, Long, Float, Double, Number, ...
Java 有8种基本数据类型: byte int short long double float Boolean char byte int short long 都属于整数类型. Double float 属于浮点类型. Boolean 为布尔类型 Char 为字符型 String 不是基本数据类型.它定义的...
floatdouble = doublelong = long (int64)int = int32编写Python文件: Pick your Class Name vicely..it will be the main name type for the generated files and Protocol/Struct name代码: clas
float anyfloat = 3.14f; // and we can use it Console.WriteLine(string.Format(anystr, anynuber, anyfloat)); // we can write functions string test1(int i, string s) { return s + " " + i; } double ...
格式-Menampilkan-Titik-Desimal Bahan Ajar基础... ios::showpoint digunakan untuk menampilkan titik desimal pada bilangan yang tidak mempunyai titik desimal pada tipe data float atau double。 Lihat源代码:
The CONSTANT_Double_info Table The CONSTANT_Class_info Table The CONSTANT_String_info Table The CONSTANT_Fieldref_info Table The CONSTANT_Methodref_info Table The CONSTANT_InterfaceMethodref_info...
float BeginX, float BeginY, float EndX, float EndY, int ArrowBegin, int ArrowEnd, int DashStyle=-1, int Style=-1, float Weight=-1); //FuncName: xls_save //function: save the file after write all ...
10) uClibc's math library only supports long double as inlines, and even then the long double support is quite limited. Also, very few of the float math functions are implemented. Stick with double ...