"Some of the reports have made this point, that there is a new kind of violation floating around.
VOA: standard.2009.06.21
So both of these stories involve floating point values, but only in this case am I actually allocating memory.
所以这两个故事都涉及到浮点类型,但是只有那样我们才能真正地分配到内存。
C So here I'm declaring a variable called c, and I'm pretty much translating the formula from the slide using the characters on my keyboard to a floating point value.
这里我声明了一个变量,然后我把那个幻灯片上的公式,用键盘上的字符翻译成了,浮点数值。
Last thing to say is why would you want to have exceptions? Well, let's go back to that case of inputting a simple little floating point.
最后要讲的是为什么有异常处理?,回到输入一个简单的小浮点数的例子,如果我期望主要是。
It just throws the decimal point away and that's because, again, these are ints and the answer intuitively should be a floating point value, but I need to be more specific.
它直接把小数点后面的数值丢弃掉了,因为,凭直觉,那些整型数和结果应该是一个浮点数据,但是我需要一个更精确的数值。
So what that means is the compiler is actually going to first "cast" so to speak 13 from whatever it is - to a float -- to a floating point value -- and then perform the division for us.
所以这里的意思是编译器将,做“计算“,譬如13这样一个浮点数,-到另一个浮点数-,然后为我们处理除法。
Here I actually need to tell the computer, "Give me some bytes in ram in which to store a value, and that value's going to be a floating point value."
这里我的确需要告诉计算机,“给我一些字节内存,来存储一个值,那个值将是,浮点型的数值“
0 >> David: Yeah, so I very deliberately changed this 9 to a 9.0 so that my math would actually be floating point math involving real numbers and not just integers.
>,大卫:是的,我故意地把9改成9,那样我的数学实际上就是浮点数的了,包括实数,不只是整数。
You can run into issues of things like overflow, underflow, with floating point numbers and when you see a whole bunches of ones, it's particularly a good time to be suspicious.
来看看哪儿会出问题,你可能会碰到浮点数中的溢出和下溢问题,当你碰到一系列这种问题后,可能就会适时的开始怀疑结果的正确性。
Need to get the base in. Second thing I want to do, I need to get the height, so I'm going to input a value for the height, also as a float, a floating point.
也就是输入底的值,第二件我想要做的,事情就是得到三角形的高,因此我会输入一个值作为三角形的高,同样也是一个浮点数。
There's no decimal point; there's no point zero; there's no floating point value, it's just a hardcoded integer.
这里没有小数点,这里没有;,这里没有浮点数值,它只是一个整型数字。
ReadFloat We'll look at it in a second. Let me sort of set the stage up for this -- suppose I want to input -- I'm sorry I want you as a user to input a floating point number.
名字叫,我们来看一会,我先来设置下情景-,假设我想输入,抱歉,我希望你们作为用户来输入一个浮点数。
And I can fix this just by changing one of those values to a floating point.
所以我可以通过改变其中一个,整型数为浮点数。
So a floating point value again is a number with a decimal point, so it depends.
一个浮点型数据就是一个,带小数点的数。
Instead divide an int by a floating point value.
我们用一个整型数除以浮点数。
GetFloating-- GetFloating-- GetFloat for a floating point number.
还有-,得到一个浮点型的数据,并赋给一个浮点型的指针。
If we did that, if we moved f minus 32 over to the left, that would give me a floating point answer because f is a float.
如果你那样做,如果我们把,放前面,那将会给我们一个浮点数答案,因为f是浮点数。
It's defined in CS50's library; its sole purpose in life is to ask the user for a floating point value and return it.
它被定义在CS50的函数库中,它的唯一目的是,向用户询问一个浮点数的值,然后返回它。
So this is something that we would call an integer, or an INT. And this is something we would call a floating point, or a float.
这是我们称之为integer的类型,或者INT,这是我们,称为浮点数的类型,或者浮点。
> But isn't f already a floating point?
>,但是f不是已经是一个浮点数了吗?
Now, a float is floating point value.
由于,float就是一个浮点数值。
应用推荐