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 a floating point value again is a number with a decimal point, so it depends.
一个浮点型数据就是一个,带小数点的数。
Secondly, that those values are discrete.
其次,这是一些离散型数据。
So, a 32 bit of float gives you a bunch of precision.
2比特的浮点型数据精度更大。
So with an integer, an int data type, you can store any number between 0 and 4 billion roughly.
只要有一个整数,一个int型的数据,就能储存任意一个,位于0到40亿之间的一个数。
> Okay. Well, this code allocates a new integer pointee and this part sets x to point to it.
>,好的,呃,这段代码分配一个新的整型指针数据,这部分让x指向它。
GetFloating-- GetFloating-- GetFloat for a floating point number.
还有-,得到一个浮点型的数据,并赋给一个浮点型的指针。
And then LLD, we'll see in a moment, this is for particularly long numbers which will become relevant especially as you're trying to process lots of information.
然后是lld,我们等会就会看到,这个代表长整型数据,它是相当重要的,特别是当你需要,处理大量信息的时候。
This is convention, so on almost-- and most any computer you overuse, if you're writing code that uses a char, you're gonna be handed 8 bits or 1 byte to store that particular char.
这是约定,对于大多数-,电脑,当你写代码要用到一个char型数据时,必须先预留8比特或1字节,的空间来存储这个char型数据。
So this line here declares a variable, just storage space called "x" and it's of type "int," which means an integer has to go in it.
这里的这条线声明了一个变量,一个叫做“x“的存储空间,它的类型是“int“,意思是里面存储的是整数型的数据。
malloc I'm going to now use this new, fancy function called malloc and I'm going to say x gets the return value of malloc of the size of an int.
我现在使用这个新的,别致的函数,然后我指明x,=,malloc的int型数据的大小,的返回值。
If you want to do the opposite process, you simply "cast to an int from a char."
如果你想做相反的转换,你就告诉计算机,“把那个char型数据转换成int型处理“
A If you want to convert a number like 65 to the letter A, you just have tell the computer "cast that int to a char."
如果你要把一个像65这样的数字转换为字母,你只需要告诉计算机“把那个int型数据转换成char型处理“
So a char size is 1 byte or 8 bits.
一个char型数据占据1字节或8比特。
So it's an address, it's a pointer, address pointer, synonyms for now, so it's the address of a char so this makes sense because s1 is also the address of a char so if I wanted to make a copy of that address this is absolutely the right syntax.
是一个地址,是一个指针,地址指针,也就是,char型数据的地址,这是有意义的,因为s1也是一个char型数据的地址,所以如果我想要复制那个地址,这个绝对是正确的语法。
But one of the teaching fellas also passed long to us recently, a little real world example of what happens when you're not mindful of various data types and you're not mindful of the imprecision that's inherent in representing data in a computer, at least using a language like C and low level primitives like floats and even doubles.
最近有个助教告诉我们,一个现实世界中的例子,当你不注意各种各样的数据类型,也不注意在计算机中表示数据时,其内在的不精确性,至少在用像C语言,和float甚至double型数据时,那将会发生什么?
应用推荐