当前位置:网站首页>Integer times integer overflow
Integer times integer overflow
2022-07-23 12:54:00 【18 ARU】
Let's look at an example , Put two 32 Bit Int Type number multiplication , Assign the result to long Type variable .long a=111111 * 111111;
At first glance, there seems to be nothing wrong with it , But this is a pit , Jump carefully ! The value after multiplication will overflow .
reason :
For compilers ,int and int Multiply , The result also exists first int in , With be assigned to long still longlong Fields of data type have no relationship .
terms of settlement :
Want not to overflow , Just put two 32 Bits are forced to long type , Multiply again .
边栏推荐
- C #: quick sort. If there is the same number, it will be ignored, and then continue the previous search direction to find the next number that meets the requirements for replacement
- Instant messaging websocket
- Understand the article frankly and get the HTTP protocol cache
- Analysis of inheritablethreadlocal and Alibaba's transmittablethreadlocal design ideas
- Learning diary - (routing and switching technology) ACL access control list
- GameFramework:资源热更代码分析,检查版本信息,下载版本文件,校验版本文件,得到更新文件数量,下载文件,TaskPool
- Hcip --- mGRE comprehensive experiment
- psutil监控的简单使用
- 手动配置DHCP服务
- Unity3d+gameframework: resource analysis, resource dependency, circular dependency detection
猜你喜欢

Depth first find all simple paths from vertex u to vertex v in the graph

Analysis of inheritablethreadlocal and Alibaba's transmittablethreadlocal design ideas

Unity3d:场景加载 GameObejct上脚本执行顺序

Super easy to use packet capturing tool tcpdump

@RequiredArgsConstructor注解使用

Hcip - HDLC and PPP protocols

浅做一下思科实验吧!

学习日记(路由与交换技术)——浮动静态路由和缺省路由

深度优先找出图中顶点U到顶点V的所有简单路径

Instant messaging websocket
随机推荐
直白理解一文搞定http协议缓存
Article on the basic technology needed to build hybrid app
Knowledge points and skills of Wireshark network analysis is so simple
在二叉排序树中删除节点
Hcip - HDLC and PPP protocols
Explain the release of TCP connection in detail
Unity3d: script execution sequence on scene loading gameobejct
详解TCP分段与IP分片
为什么要搭建本地yum仓库?
简洁描述raft与paxos在设计上的共同点和不同点
Homework of the fifth week
HCIP---BGP相关配置(联邦篇)
Htpasswd action
以go语言为例类比侦探推理来讲解【性能分析】
DHCP 第二次实验
记一次日志文件IO系统的设计心得
Instant messaging websocket
Unity shader missing problem
【数据库】基础理论
[database] basic theory