Answer the question
In order to leave comments, you need to log in
How to come to a decision? C programming?
Got a few questions, can someone answer?
1.
Listing: https://gist.github.com/kobylinsky/7955e2166b48463...
Is everything correct?
2. warning C4244: =: convert "double" to "float", possible data loss -- how to fix this? Is there really data loss or is it nothing?
3. What is the difference between fabs and abs?
4. What is the difference between <match> and "match" - why quotes are used in one library, and the equation sign in another.
Rookie student. Please don't throw stones.
Answer the question
In order to leave comments, you need to log in
2.Data loss occurs. A trifle or not - depends on the task. In your case, a trifle, in others - no.
All real constants in your code are doubles, so all your variables are converted to double during calculations, the result is calculated as double and converted to float to store the result.
To remove the message:
- make all variables double or
- add the suffix f to all constants, for example: 1.f - then the constants will be float and all calculations will be performed on float - there will be no losses, because there will be no type conversion.
3.fabs - for real numbers, abs - for integers. fabs is defined in math.h, abs is in stdlib.h
4. Usually quotes are used in #include for their headers, for system/library headers - <>. Their difference is that in "" the header search starts from the directory where the current compiled file is located, then in all other places known to the compiler. For <>, the current directory is not searched, so the compiler may not find your own headers (unless you specify the -I option).
https://en.cppreference.com/w/c/preprocessor/include
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question