icon 字幕
正在加载字幕...

Rust Tutorial #6 - Arithmetic and Type Casting

youtube 翻译 youtube 中文翻译 youtube 字幕 youtube 中文字幕 youtube 翻译成中文 youtube 视频翻译 youtube translate to chinese translate youtube to chinese youtube transcript to chinese translate youtube video to chinese

YouTube transcript, YouTube translate

32/32

A quick preview of the first subtitles so you know what the video covers.

hello everybody and welcome to video 6 in this rust programming tutorial series in this video i'm going to be going over arithmetic so really math here in ross with different data types as well as how we perform type conversions and how we cast one type to another this is an important video you may think you know how to do basic arithmetic but if you've not done it in a statically typed language then please watch through because there's a lot of nuances and stuff you need to understand especially related to stuff like overflows which we're going to talk about a fair amount now of course i will mention i do have my course programming expert dot io if you made it to video six check it out it's in the link in the description genuinely a great resource we've had some great feedback on it so far and i spent an incredible amount of time working on that course i promise you it's some of the best work that i've ever delivered so if you like this teaching content then definitely check that out anyways with that said let's dive in here at some basic variables here and start to kind of get into arithmetic going to say let x is equal to 9 and don't forget my semicolon this this time and then let y equal 10. now we know by default these are going to be i-32 but i'm going to change these to be u8 and 2b now first thing i'll show you is we do have a comment in rust i should have mentioned this earlier but a comment is with two forward slashes now anything after these two forward slashes on the same line will not be read by the compiler it will just be ignored as a comment and what i'm going to do here is just put the range of my uh what do you call it my u8 which is 0 to 255 and then the range here for my i8 we know is going to be negative 128 to 127. now the reason i'm doing this is i want to show you what happens if i put a value here that's outside of the range of this type so for example if i do something like 256. now it may seem obvious but if i go here and i run my code you're going to see that i get an error and it says that the value 256

设置

100%

翻译目标语言

🔊 音频播放
正在播放翻译音频