B;
MaaKa
MaaKa
There’s no need to get mad brother
Just understand an accept the fact that he was trying to help
But the help he provided wasn’t enough, and your both good 😊
P
Danya🔥
Wtf is going on here
B;
okk
So you get it now after two people told you the same thing
MaaKa
B;
Well nice. 👍
B;
Check this one
B;
https://pastebin.com/rCmkPdN5
Garbage value is getting printed idk why
B;
I recon it has something to do with indexing.
David
need a dev to code please
MaaKa
MaaKa
Code real world projects?
David
yes please
MaaKa
yes please
Ohh okay
Someone may show up anytime soon
I’m still working on console applications 😪
David
Chijioke
Pls, what is the interpretation to;
name[strlen(name)-1] = ' \0'
Chijioke
🙏Thanks. That is the '\n' now become '\0' , right?
Alexandr
I have some kind of message bus in my application and i need to track several int values at once. But this bus just for float type values. Is it save enough to reinterpret float as 4 uint8_t numbers? Or it depends on OS primitive sizes or something else?
Ludovic 'Archivist'
Alexandr
Is there some safe way? I need only two uint8_t btw
Chat Boss
Alexandr sent a code, it has been re-uploaded as a file
Daniel
在一个相当奇怪的时钟的表面上,小时数是从 1 到 12; 此时短针和长针都指向12。短针每小时顺时针移动2个数字,长针每小时顺时针移动3个数字。 多少小时后两根指针会再次指示相同的数字?
(一) 8小时
(b) 15 小时
(c) 指针再也不会指示相同的数字
(d) 12 小时
(e) 19 小时
Danya🔥
Danya🔥
Sanchit
Double d = 456.54578 shows in c++ code while debugging is 456.545779999999998
Sanchit
Can anyone know any method of how i can take only 4 digits after decimal point for calculation in our code in decimal datatype
Sanchit
Is there any way that my decimal number will store only number like this - 456.5457
Danya🔥
Sanchit
Actually i am doing calculation on all the numbers which contains decimal points
Sanchit
klimi
klimi
why do you need to take only part of it?
Sanchit
I want only four digits after decimal point i hope now you can understand
klimi
Ehsan
Is there any way that my decimal number will store only number like this - 456.5457
hi
i don't understand why are you interested in what precision debugger shows you, i think based on IDE you are using there are ways in the IDE's settings to show you specific number of digits after decimal point. but if you want a specific precision in your calculations float point is not your best choice. float points are based on IEEE 754 standard which is composed of sign bit, mantissa part and exponent part and based on your value uses the best precision and rounds it. if you want a specific precision in your calculations you better use fixed point arithmetic.
and if you are interested in number of digits on console you must use iomanip library using fixed and setprecision(4) methods. google it.
i hope it clear things a bit for you.
Sanchit
Sanchit
I know for console we have set precision method but i want to store only 4 digits after decimal point in a float or double variable
Sanchit
Is there any method for this
Ehsan
Is there any method for this
see if this works for you:
#include <iostream>
#include <cmath>
int main() {
float num = 3.14159265359;
float truncated = std::floor(num * 10000.0f) / 10000.0f;
std::cout << truncated << std::endl;
return 0;
}
MaaKa
Use this code
It should work perfectly 🫠
Chat Boss
MAKA sent a code, it has been re-uploaded as a file
klimi
storing numbers as string is not recommended btw
klimi
it is unnecessary, you take memory without reason, you need to covert it and like you mentioned you cannot do arithmetic
klimi
there no reason to do arithmetics only on 4 decimal places if you have a float, this is just not how float works, if you want to work with decimal numbers, you will have to implement this by yourself
klimi
yeah, he didn't say he wanted just to print it or store it as string
Majid
Hello friends you have a complete binary tree training resource do you?
klimi
Majid
Guillermo
It has a lot of theory about algorithms, not just BST's but a lot of more with practical exercises
Asiman
Hello guys. Is there any way to use vector of different object types but same parent class?
Chat Boss
D45 sent a huge message, it has been re-uploaded as a file
hello i want to write a project, in which i want to use same class function in the another class..
Anonymous
Pavel
can anybody help me with this?
You added definitions for new functions, instead defining your functions of the class, it should be something like this instead:
int someClass::functionOne() {
...
}
void someClass::functionTwo() {
..
}
Anonymous
Anonymous
hello i want to write a project, in which i want to use same class function in the another class function is it possible? for example:
class someClass {
public:
int functionOne();
void functionTwo();
};
int someClass::functionOne() {
// some code
functionTwo(); // how to do this?
// some code
}
void someClass::functionTwo() {
// again some code
}
Pavel
Pavel
Pavel
Anonymous
Pavel
Are you sure you don't add the prefix for the declarations? Are you sure your real code looks the same way as the example?
Asiman
Anonymous
Pavel
Anonymous
Pavel
not for me, may i send the code for you?
No, no need to.
Just check that you don't have the prefix in your function declarations inside the class. Note that in the error the compiler prints there's the line number printed where the error occured, you need to check that line.
Anonymous
Anonymous