Rust Tutorial #6 - Arithmetic and Type Casting

  Рет қаралды 67,378

Tech With Tim

Tech With Tim

Күн бұрын

Пікірлер: 83
@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 2 жыл бұрын
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!
@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
@unicorn_tamer
@unicorn_tamer 2 жыл бұрын
I can finally watch another coding video on my two monitors after almost 2 years!
@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
@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
@michaelsciortino3385
@michaelsciortino3385 Жыл бұрын
Damn I can bbq a whole cow with all the roasting going on in the comments here about 255/10
@gjermundification
@gjermundification 10 ай бұрын
13:26 This is most likely the smallest number allowed by i32 as fo i8::Max + 1 = -128
@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.
@jasongracae1780
@jasongracae1780 2 жыл бұрын
Tim: "So that's all really all I want to show in the video". Wow so short!
@playniuniu
@playniuniu 2 жыл бұрын
Thanks so much for this tutorial.
@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.
@jasongracae1780
@jasongracae1780 2 жыл бұрын
Isn't that 'INVISIBLE CHARACTER'🧙🏻‍♂ just a ? Or there is some other thing too?
@sirbackenbart
@sirbackenbart 5 ай бұрын
Yes, it is a . trim only removes "whitespaces" (prefixed & suffixed) which are defined to also include linebreaks.
@codeandtalk6
@codeandtalk6 2 жыл бұрын
Waiting for this video
@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
@gabehcuodsuoitneterp203
@gabehcuodsuoitneterp203 2 жыл бұрын
What is casting with the underscore and without the keyword 'as' really doing?
@m-zurowski
@m-zurowski 2 жыл бұрын
@6:51 - my brain starts singing USA's anthem
@djemi3etelminigeekandhacke343
@djemi3etelminigeekandhacke343 11 күн бұрын
The errors you presented in rust such as overflow or adding data of two different types, why these kind of errors are not reported in C such as adding long int with short int, or adding unsigned int with signed int ?
@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 😂
@subee128
@subee128 2 жыл бұрын
Thanks
@patricklittle1002
@patricklittle1002 2 жыл бұрын
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?
@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
@maker._
@maker._ 6 ай бұрын
I wonder why, if x and y were f64 and they enforce the need for decimal, why was x * y not 2550.0? 🤔
@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
@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.
@tudormurariu8016
@tudormurariu8016 2 жыл бұрын
Is this assembly? :))))
@kevinwalters2887
@kevinwalters2887 5 ай бұрын
I have a feeling they named it 'rust' is bc it's the reheaded step-child you gotta tell it everything! lol
@jasongracae1780
@jasongracae1780 2 жыл бұрын
9:10 Why would I want that?
@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💀
@tag_of_frank
@tag_of_frank 2 жыл бұрын
need more explanation of parse + unwrap why is that needed don't get it
@pravachanpatra4012
@pravachanpatra4012 2 жыл бұрын
Can you collab with tiff in tech
@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 😁
@kirbofn524
@kirbofn524 9 ай бұрын
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
@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.
@doropomegranate
@doropomegranate 2 жыл бұрын
I miss javascript
@MountainLabsYT
@MountainLabsYT 3 ай бұрын
255 / 10 = 25.5
@genericbinary558
@genericbinary558 6 ай бұрын
I am ben tennision.
@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 🤦‍♂
@ryan80166
@ryan80166 2 жыл бұрын
finasteride and minoxidil
@ЗубайрРахимов-щ7ы
@ЗубайрРахимов-щ7ы 2 жыл бұрын
hi Tim How old are u ? i sad my teacher that u r 19 and he replies me "FALSE"
@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.
@webpapi
@webpapi 11 ай бұрын
python is far simpler w/less code :/
@unitazer
@unitazer 6 ай бұрын
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--
@Xylys
@Xylys 2 жыл бұрын
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 2 жыл бұрын
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
Рет қаралды 187 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,3 МЛН
[BEFORE vs AFTER] Incredibox Sprunki - Freaky Song
00:15
Horror Skunx 2
Рет қаралды 20 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 36 МЛН
Rust Tutorial #8 - Functions, Expressions & Statements
16:33
Tech With Tim
Рет қаралды 50 М.
I spent six months rewriting everything in Rust
15:11
chris biscardi
Рет қаралды 445 М.
Coding Was HARD Until I Learned These 5 Things...
8:34
Elsa Scola
Рет қаралды 771 М.
How to Build a Freelance Coding Career - ft. @NicolaiAI
18:36
Tech With Tim
Рет қаралды 14 М.
Rust Tutorial #4 - Data Types
17:20
Tech With Tim
Рет қаралды 99 М.
Rust Tutorial #9 - Memory Management, Heap & Stack
21:27
Tech With Tim
Рет қаралды 62 М.
Rust for the impatient
10:43
No Boilerplate
Рет қаралды 749 М.
Linux File System/Structure Explained!
15:59
DorianDotSlash
Рет қаралды 4,2 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,3 МЛН