当前位置:网站首页>四字节的float比八字结的long范围大???
四字节的float比八字结的long范围大???
2022-08-02 08:22:00 【DNS是域名服务器】
学习上周在学Java的自动类型转换的时候,学习4字节的float能够存储的范围居然大于8字节的long。以往在学编程语言的时候,基本上都不会去记数据类型的取值范围,也没有比较过这两个数据类型到底谁的范围更大,4字节的float为何表示的范围能大于8字节的long呢?
主要的原因是因为浮点类型和整数类型的存储结构不相同,整数类型在计算机底层采用补码方式存储,除去首位的符号位,剩余的位数即表示数值的范围,也就是位数越多,范围越大,比如long在内存中占用8个字节共64位,符号位占一位,数值范围是-2的63次方到正2的63次方-1。那么对于单精度浮点数float是采用这样的结构存储的,当然了double的结构也是这样,只不过double是8个字节(32位)的。
float:4个字节 long:8个字节
整数与小数的底层存储有点不同。
相同点:
它们都是用二进制存储的
不同点:
小数先转成二进制,然后处理,然后存储。


符号位 其中最左边的为符号位,0为正,1为负。
指数 接下来的E是指数,一共8位,也用二进制来表示。IEEE规定,在float类型中,用来计算指数的偏移量为127(即存贮指数时要在原基础上+127)。
尾数 最后的F是小数部分,尾数正是由这23位的小数部分+1位组成的。
边栏推荐
- Stop mental exhaustion Daily sharing
- Redis分布式锁入门
- cas: 139504-50-0 Maytansine DM1|Mertansine|
- 了解下C# 多线程
- 知识点滴 - 为什么一般不用铜锅做菜
- Ansible learning summary (11) - detailed explanation of forks and serial parameters of task parallel execution
- AttributeError: module ‘clr‘ has no attribute ‘AddReference‘
- oracle的sql改成mysql版本
- HCIP笔记十六天
- Spark 系统性学习笔记系列
猜你喜欢

pnpm:简介
![Detailed explanation of calculation commands in shell (expr, (()), $[], let, bc )](/img/3c/5cc4d16b9b525997761445f32802d5.png)
Detailed explanation of calculation commands in shell (expr, (()), $[], let, bc )

Biotin-EDA|CAS:111790-37-5| 乙二胺生物素

A young man with strong blood and energy actually became a housekeeper. How did he successfully turn around and change careers?

Redisson报异常attempt to unlock lock, not locked by current thread by node id解决方案

MySQL Workbench 安装及使用
![shell中计算命令详解(expr、(())、 $[]、let、bc )](/img/3c/5cc4d16b9b525997761445f32802d5.png)
shell中计算命令详解(expr、(())、 $[]、let、bc )

PyCharm usage tutorial (detailed version - graphic and text combination)

测试时大量TIME_WAIT

Biotin hydrazide HCl|CAS:66640-86-6|Biotin-hydrazide hydrochloride
随机推荐
普林斯顿微积分读本03第二章--编程实现函数图像绘制、三角学回顾
Shell becomes canonical and variable
Figure robot software digital twin station oil and gas pipelines, oil and gas transportation control platform
pnpm的安装与使用
Biotin-C6-amine|N-biotinyl-1,6-hexanediamine|CAS: 65953-56-2
OneNote 教程,如何在 OneNote 中创建更多空间?
自定义table表格
UVM信息服务机制
Business Intelligence Platform BI Business Intelligence Analysis Platform How to Choose the Right Business Intelligence Platform BI
Shell变成规范与变量
抓包工具Charles修改Response步骤
编程与哲学(2)——输出是为了更好的输入
小康股份更名赛力斯,如何走出一条高端产品的“丝绸之路”?
力扣:第 304 场周赛
pycharm的基本使用教程(1)
Docker内MySQL主从复制学习,以及遇到的一些问题
QT web development - Notes - 3
IO process thread -> process -> day4
轴流式水轮机隐私政策
etcd implements large-scale service governance application combat