隆中浮动,为什么呢? [英] Long in Float, why?

查看:137
本文介绍了隆中浮动,为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 长B = 99; 
浮法C = 99.0F;
// B = C; //错误:无法隐式转换类型浮动到长。
C = B; //成功运行。为什么?



为什么会出现有关数据类型的大小和隐式转换没有问题?结果
浮动是不同的,因为我们知道,哪些是如下...

$的大小b
$ b

  Console.WriteLine(长:+的sizeof(长)); //输出 - >长:8 
Console.WriteLine(浮动+的sizeof(浮动)); //输出 - >浮动:4


解决方案

一个浮动的范围(约±3.4E38 )是的的比长的范围内(约±9.22e18),即使长期具有较高的精度更大。


long b = 99;  
float c = 99.0F;  
//b = c; //Error : Cannot implicitly convert type 'float' to 'long'.
c = b; // Running Successfully.  Why?

Why is there no problem regarding size of data type and implicitly converting?
The size of float and long is different as we know and which is given below...

Console.WriteLine("Long  : " + sizeof(long)); // Output --> Long : 8
Console.WriteLine("Float : " + sizeof(float));// Output --> Float: 4

解决方案

A float's range (approx ±3.4e38) is much larger than a long's range (approx. ±9.22e18), even though a long has higher precision.

这篇关于隆中浮动,为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆