Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
coolq48207y@ComradeBob
Ahhh, it makes so much sense!
Thanks for the explanation π
Why doesn't C++ pick up that 'i' is an integer though? Would have thought an error would have come out of that? -
@ComradeBob thanks for telling... I understood that π... but I just find it kinda funny...
M very sure I don’t wanna look at a codebase using something like:
-2[ arr ];
It is confusing π π
Ur comment shall b useful for many people though π€ -
theNox92717yWe learned all these things last year π (we were literally drilled to know all those things)
-
@coolq it simply doesn’t matter...
I believe what happens is that one type can auto change at times to work with another one if the vice verse isn’t possible π€ -
@coolq something like how,
If I write:
int p = 10 + ‘c’ + 48;
‘c’ is auto converted to int to make things work...
This is how I understand it anyways...
I also thought first that it wud b an error π -
All chars are basically numbers, you can find them in the Ascii table.
For instance, if you want to turn your char array into all uppercase, write carr[i]+32 -
@ComradeBob yea that is true... it is just my style of understanding how the compiler understands its semantics π π
Probably wrong style though... do enlighten with ur take plz π€ -
It will do a cast to int, something like static_cast<int>('c') I guess. Might ve a bit different since your 'c' is a const char, but about the idea. Cast = convert, in case you don't know the verb. Helps with stackoverflow searches
-
coolq48207y@ComradeBob
@Electrux
I find this stuff useful because I'm writing my own simple C compiler for my own CPU type, it's a very simple CPU, and this gives me insight as to how a C++ compiler works.
Thank you π -
@coolq holy cow!!! Do tell me when u have a version done plz π²π²ππ
And good luck with it too...
Glad I helped with something π -
coolq48207y@Electrux
I might post a picture of it when I'm done, it's called a breadboard CPU π
So far I've been making my design in a logic simulator, it's looking promising π
Making your own compiler is a problem with having your own architecture. I'm wondering if I could translate another? Perhaps C2BF?
Thanks for your interest! -
@coolq lol I feel like I m doing nothing now... kudos to ur project man βπ»π€π»βΊοΈβΊοΈ
-
@Autism420 seems to have something to do with 3 decimal places... can’t seem to understand what though ππ€
-
@Autism420 nvm the above comment then π€£π€£
That’s so cool!!! πππ€π»
Thanks a million π€π€ππ»ππ» -
@Autism420 just did some reading on it... now I wanna thank u in person ππ»ππ»ππ
On the other hand I wanna forget programming an reboot πππ -
@Artemix I think I understood some of the words you said. Can you explain it in stupid? If I understand correctly, lvalues cant be const for instance, such as 1 = x; but x = 1; is possible, as x is both l and rvalue and 1 is an rvalue.
-
@ComradeBob as I read, any value which has a location to store data which can be modified is an lvalue π
Seems to b sufficiently correct till some exception pops up -
@Electrux that makes sense, the compiler likely replaces things such as const int with its respective value in the code and doesnt reserve memory
-
@ComradeBob although... I do think that it simply checks if the possibly lvalue is actually a const or something in which case it no longer is an lvalue hence the statement wud b incorrect
-
crisz81917yEveryone is saying "thank you", but if the same thing happened in JavaScript now everyone would complain about how crazy is the language
-
@crisz maybe because people r used to this type of stuff in Java, but not in C++?
And well, things do make sense if u try to understand deep enuf (although I hate where C++ is going these days :(
)
Maybe they make sense in JS too... idk that language so no comments there π€ -
QCat8047y1. Is because the comparison is made between mantissas of different values due to precision differences
-
Double-A4347yThat's why you don't compare float values like that... Check if the difference is smaller than some tolerance value.
-
Celes6877yFloat is mostly used with GPU. Default is double. So just put 5.9f if you want the float version.
Related Rants
So... I learnt a couple things today about C++ language which I didn’t know before...
1. float var = 5.9;
std::cout << ( var == 5.9 );
// shows 0 (false) coz of float and double thing... apparently, 5.9 isn’t automatically converted to float when compared to one π€
2. arr[ i ] == i[ arr ]
Well... I guess I now like my college 1% more from the previous % whatever that was πβΊοΈ
rant
thank you maβam and sir
i learnt at college
new
happy
π
thanks college