Rust Tutorial #6 - Arithmetic and Type Casting

  Рет қаралды 64,750

Tech With Tim

Tech With Tim

Күн бұрын

Пікірлер: 84
@TheRedPython
@TheRedPython 2 жыл бұрын
6:48 “I don’t know exactly what 255 divided by 10 is” 😭
@luigi-fan554
@luigi-fan554 2 жыл бұрын
I wonder what 255 divided by 10 is, hmm, tricky question
@TheSpartacusS
@TheSpartacusS 2 жыл бұрын
I laughed too hard at this :D
@jasongracae1780
@jasongracae1780 2 жыл бұрын
I paused the video, exited full screen and scrolled down to the comments to type the exact same thing. 😒
@eineatombombe
@eineatombombe 2 жыл бұрын
this guy is here being a software engineer and teaching us rust while not knowing what's 255/10
@bravobessa3684
@bravobessa3684 2 жыл бұрын
😀
@m-zurowski
@m-zurowski 2 жыл бұрын
jokes aside - some ppl at third year of mechanical engineering at my university need to use a calculator for exactly that sort of 'arithmetics' XD
@philaskytech
@philaskytech Жыл бұрын
Be easy on yourself, I like seeing the little mistakes; helps us all learn. These tutorials are amazing, and you are clearly very good at teaching and understanding CS. Thanks TIm!
@jasongracae1780
@jasongracae1780 2 жыл бұрын
Python: int_input = int(input1) Rust: let int_input: i64 = input.trim().parse().unwrap(); Tim: We can now just print it!
@Eva-tf5ud
@Eva-tf5ud 2 жыл бұрын
This rust line does nothing without input variable (let mut input = String::new(); io::stdin().read_line(&mut input).expect(" ");) this should also be included
@unicorn_tamer
@unicorn_tamer 2 жыл бұрын
I can finally watch another coding video on my two monitors after almost 2 years!
@someshvemula9966
@someshvemula9966 2 жыл бұрын
As always, liked your video even before watching it.
@TechWithTim
@TechWithTim 2 жыл бұрын
MVP
@tama3442
@tama3442 2 жыл бұрын
*What is the Gospel?* The true gospel is the good news that God saves sinners. Man is by nature sinful and separated from God with no hope of remedying that situation. But God, by His power, provided the means of man’s redemption in the death, burial, and resurrection of the Savior, Jesus Christ. Ephesians 2:8-9 For it is by grace you have been saved through faith. And this is not your own doing; it is the gift of GOD, not a result of works, so that no one may boast. Romans 10:9 9 because, if you confess with your mouth that Jesus is Lord and believe in your heart that God raised him from the dead, you will be saved. JESUS CHRIST can come anytime! REPENT OF YOUR SINS Just Believe ❤️ Love you and GOD BLESS
@therealworldlibrary
@therealworldlibrary 2 жыл бұрын
@@tama3442 yeah no I don't give a damn
@richardneumann3335
@richardneumann3335 Жыл бұрын
13:14 And this is why you should not use "as" to convert integer types but "from()" or "try_from()" respectively and handle possible errors.
@lazerpie101
@lazerpie101 Жыл бұрын
A couple notes: integer division in Rust will always round down using the unwrap_or({backup_value}) instead of just unwrap() will prevent runtime errors
@playniuniu
@playniuniu 2 жыл бұрын
Thanks so much for this tutorial.
@introspecticon
@introspecticon 2 жыл бұрын
I'm surprised the compiler didn't catch the i32::MAX + 1 overflow. Wonder if that's intentional or an oversight
@DuskyDaily
@DuskyDaily 2 жыл бұрын
It's not actually i32::MAX + 1, but it's (i32:MAX as i64) + 1. I mean i64 can store i32:MAX + 1. So overflow occurred when it tried to convert it back to i32 at line 5. I guess, that's how it works.
@lukeh7052
@lukeh7052 2 жыл бұрын
When printing an f64, why doesn't the floating part appear even though it is required in rust to be an f64? Same applies to f32.
@marcotroster8247
@marcotroster8247 2 жыл бұрын
Haha this kind of pedantic errors seems very familiar. It's about the same as compiling C89 with ansi pedantic and Wall Werror. Happy coding 😂
@jasongracae1780
@jasongracae1780 2 жыл бұрын
Tim: "So that's all really all I want to show in the video". Wow so short!
@michaelsciortino3385
@michaelsciortino3385 Жыл бұрын
Damn I can bbq a whole cow with all the roasting going on in the comments here about 255/10
@gjermundification
@gjermundification 9 ай бұрын
13:26 This is most likely the smallest number allowed by i32 as fo i8::Max + 1 = -128
@jasongracae1780
@jasongracae1780 2 жыл бұрын
Isn't that 'INVISIBLE CHARACTER'🧙🏻‍♂ just a ? Or there is some other thing too?
@sirbackenbart
@sirbackenbart 3 ай бұрын
Yes, it is a . trim only removes "whitespaces" (prefixed & suffixed) which are defined to also include linebreaks.
@gabehcuodsuoitneterp203
@gabehcuodsuoitneterp203 2 жыл бұрын
What is casting with the underscore and without the keyword 'as' really doing?
@stas4112
@stas4112 2 жыл бұрын
Im honestly surprised by the many ways that you can declare the casting of a literal. I usually don't like when languages have many ways to do one thing, and I thought rust was one of those anal languages that makes everyone better by having no alternatives
@patricklittle1002
@patricklittle1002 Жыл бұрын
So literally, the compiler complains when doing normal overflow math and doesn't automatically promote, but runs just fine without warnings when that's the only time I would expect this strong language to catch something?
@subee128
@subee128 2 жыл бұрын
Thanks
@codeandtalk6
@codeandtalk6 2 жыл бұрын
Waiting for this video
@kirbofn524
@kirbofn524 7 ай бұрын
I think that not being able to devide 20 / 2 just because 20 is a i8 and 2 is a u8 is stupid. I get safety and all of that but still. That is stupid
@maker._
@maker._ 5 ай бұрын
I wonder why, if x and y were f64 and they enforce the need for decimal, why was x * y not 2550.0? 🤔
@camilo1u2b
@camilo1u2b 2 жыл бұрын
Prove that you don't need to be good at math to be a great programmer. what 255/10 is? min: 6:45
@m-zurowski
@m-zurowski 2 жыл бұрын
@6:51 - my brain starts singing USA's anthem
@bhavinnegi
@bhavinnegi 2 жыл бұрын
I checked your checkers tutorial and made it . It has a bug while triple jumping. Can u fox it 😃
@tag_of_frank
@tag_of_frank 2 жыл бұрын
need more explanation of parse + unwrap why is that needed don't get it
@kevinwalters2887
@kevinwalters2887 3 ай бұрын
I have a feeling they named it 'rust' is bc it's the reheaded step-child you gotta tell it everything! lol
@tudormurariu8016
@tudormurariu8016 2 жыл бұрын
Is this assembly? :))))
@johnbennett1465
@johnbennett1465 2 жыл бұрын
If Rust caught overflow at runtime then being so picky about types could make sense. Without that, it does nothing but annoy the programmer. C implemented a mostly reasonable set of automatic conversions for numbers half a century ago. I can see reasons for tweaking the exact rules, but no reason to not automatically do safe conversions.
@dynfoxx
@dynfoxx 2 жыл бұрын
It does catch overflow in debug mode. While i agree with you its not that much harder to get conversions by just adding .into() . Rust wants to be clear that there is a conversion happening.
@sephalopod
@sephalopod 2 жыл бұрын
How did his "println!" work there was no semicolon
@rami_atallah
@rami_atallah 2 жыл бұрын
Because it is the last thing to run. Think the semicolon in rust is same as the use of semicolon in css. (Ps: If i am wrong someone correct me)
@erfer981
@erfer981 2 жыл бұрын
when we return something (in the last line or in a function) we dont need to type a ';' if you want to type a ';' then you can use the return keyword
@pravachanpatra4012
@pravachanpatra4012 2 жыл бұрын
Can you collab with tiff in tech
@maxovicsteiner9646
@maxovicsteiner9646 2 жыл бұрын
255/10 💀
@holonaut
@holonaut 2 жыл бұрын
it's 25 and then something, not gonna calculate the exact value
@maxovicsteiner9646
@maxovicsteiner9646 2 жыл бұрын
@@holonaut someone didn't go to primary school
@unixwastaken
@unixwastaken 2 жыл бұрын
@@holonaut bruh for dividing by 10 you just move over the period to the left one time💀
@jasongracae1780
@jasongracae1780 2 жыл бұрын
9:10 Why would I want that?
@CallousCoder
@CallousCoder 2 жыл бұрын
Millenials and math 😂“I don’t know what 255 divided by 10 is but is 25 point something”. I was sitting It’s 25.5! .5!!! .5!!! 😅 Or perhaps it’s because he’s American and doesn’t use decimal system and therefore didn’t see it right away. Because in decimal system you just shift the comma. Anyways I find maths in Rust very unwieldy and you get very verbose formulas. Yesterday (hence I watched this video) I created a sine table creator for some Amiga demos I’m working on in Rust. And I was amazed that I couldn’t add an int to a float because in C that’s no problem not even with warnings all in. So I kept type casting looking at my formulas and was like: “this became utterly unreadable! Is there a better way?n And ended up here.
@MountainLabsYT
@MountainLabsYT 2 ай бұрын
255 / 10 = 25.5
@mrpancakes
@mrpancakes 2 жыл бұрын
255 divided by 10 is 25.5 lol
@tama3442
@tama3442 2 жыл бұрын
*What is the Gospel?* The true gospel is the good news that God saves sinners. Man is by nature sinful and separated from God with no hope of remedying that situation. But God, by His power, provided the means of man’s redemption in the death, burial, and resurrection of the Savior, Jesus Christ. Ephesians 2:8-9 For it is by grace you have been saved through faith. And this is not your own doing; it is the gift of GOD, not a result of works, so that no one may boast. Romans 10:9 9 because, if you confess with your mouth that Jesus is Lord and believe in your heart that God raised him from the dead, you will be saved. JESUS CHRIST can come anytime! REPENT OF YOUR SINS Just Believe ❤️ Love you and GOD BLESS
@murphygreen8484
@murphygreen8484 2 жыл бұрын
*255 divided by 10 is 25.5. If you can make an easy mistake pointing this out I think we can let him make a mistake while trying to talk on camera 😉
@michealhall7776
@michealhall7776 2 жыл бұрын
You probably just googled that
@mrpancakes
@mrpancakes 2 жыл бұрын
@@murphygreen8484 hahahahaha, watcha talkin about 😁
@doropomegranate
@doropomegranate Жыл бұрын
I miss javascript
@bifidoc
@bifidoc Жыл бұрын
this: ```rust fn main() { let x:u8=128; let z:u8=64; let y:u8=x+z+z; println!("{y}"); } ``` overflows in runtime 🤦‍♂
@genericbinary558
@genericbinary558 4 ай бұрын
I am ben tennision.
@ЗубайрРахимов-щ7ы
@ЗубайрРахимов-щ7ы 2 жыл бұрын
hi Tim How old are u ? i sad my teacher that u r 19 and he replies me "FALSE"
@ryan80166
@ryan80166 2 жыл бұрын
finasteride and minoxidil
@webpapi
@webpapi 9 ай бұрын
python is far simpler w/less code :/
@unitazer
@unitazer 4 ай бұрын
My brother in christ, python is a dynamic language, which means that it gets compiled into bytocode while being executed, which makes it EXTREMELY slow. This is basically c++ if it wasnt c--
@Hacker097
@Hacker097 2 жыл бұрын
Rust really leaves no room for ambiguity
@tama3442
@tama3442 2 жыл бұрын
*What is the Gospel?* The true gospel is the good news that God saves sinners. Man is by nature sinful and separated from God with no hope of remedying that situation. But God, by His power, provided the means of man’s redemption in the death, burial, and resurrection of the Savior, Jesus Christ. Ephesians 2:8-9 For it is by grace you have been saved through faith. And this is not your own doing; it is the gift of GOD, not a result of works, so that no one may boast. Romans 10:9 9 because, if you confess with your mouth that Jesus is Lord and believe in your heart that God raised him from the dead, you will be saved. JESUS CHRIST can come anytime! REPENT OF YOUR SINS Just Believe ❤️ Love you and GOD BLESS
@NorteXGame
@NorteXGame 2 жыл бұрын
And that, in my opinion, is good. It leaves you with opinionated code, which everyone can easily read.
@Xylys
@Xylys Жыл бұрын
how do you not know what 255 / 10 lol
@tama3442
@tama3442 2 жыл бұрын
*What is the Gospel?* The true gospel is the good news that God saves sinners. Man is by nature sinful and separated from God with no hope of remedying that situation. But God, by His power, provided the means of man’s redemption in the death, burial, and resurrection of the Savior, Jesus Christ. Ephesians 2:8-9 For it is by grace you have been saved through faith. And this is not your own doing; it is the gift of GOD, not a result of works, so that no one may boast. Romans 10:9 9 because, if you confess with your mouth that Jesus is Lord and believe in your heart that God raised him from the dead, you will be saved. JESUS CHRIST can come anytime! REPENT OF YOUR SINS Just Believe ❤️ Love you and GOD BLESS
@dyspatch8574
@dyspatch8574 2 жыл бұрын
Are you Catholic or Orthodox?
@ohwow2074
@ohwow2074 2 жыл бұрын
Stop this $hit please
@dyspatch8574
@dyspatch8574 2 жыл бұрын
@@ohwow2074 I know it's shit, I hate religion, but I asked this bot just to see if it's even responding to such comments.
@JakkeJakobsen
@JakkeJakobsen Жыл бұрын
Oh my fucking God, please stop.
@scottb4029
@scottb4029 Жыл бұрын
God is Love. There is not fear in perfect love. 2nd Peter I believe or 2nd John.
Rust Tutorial #7 - Conditions and Control Flow (if/else if/else)
11:57
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 177 М.
What's in the clown's bag? #clown #angel #bunnypolice
00:19
超人夫妇
Рет қаралды 17 МЛН
DID A VAMPIRE BECOME A DOG FOR A HUMAN? 😳😳😳
00:56
😜 #aminkavitaminka #aminokka #аминкавитаминка
00:14
Аминка Витаминка
Рет қаралды 1,5 МЛН
Rust and RAII Memory Management - Computerphile
24:22
Computerphile
Рет қаралды 230 М.
Why I Chose Rust Over Zig
33:18
ThePrimeTime
Рет қаралды 192 М.
I spent six months rewriting everything in Rust
15:11
chris biscardi
Рет қаралды 434 М.
Why i think C++ is better than rust
32:48
ThePrimeTime
Рет қаралды 316 М.
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 315 М.
The Ultimate Tier Programming Tier List | Prime Reacts
26:57
ThePrimeTime
Рет қаралды 444 М.
Learning Rust the wrong way - Ólafur Waage - NDC TechTown 2022
51:54
NDC Conferences
Рет қаралды 106 М.
What Makes Rust Different?
12:38
No Boilerplate
Рет қаралды 203 М.
How to Learn Rust
10:36
No Boilerplate
Рет қаралды 573 М.
What's in the clown's bag? #clown #angel #bunnypolice
00:19
超人夫妇
Рет қаралды 17 МЛН