Comparing Floating Point Variable With a Value In C Programming

preview_player
Показать описание

In this video tutorial lets see how we can compare a floating point variable with a constant value, and lets see the result.

The Problem
If you assign 0.7 to a floating point variable num and then inside if condition you check if num == 0.7, it returns false. Because here variable num is of data type float and the constant value 0.7 is considered as double type data.

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert
Рекомендации по теме
Комментарии
Автор

Thank you very much you help a student in exam

JokerDSalem
Автор

Sir you are great . Their is no other video on entire youtube which can explain this topic so easily .
I was struck in this problem of comparing for almost 2 hrs and tried all the ways including some great sites like GeeksforGeeks but was unable to figure out error as they have used very difficult and complicates approach . Thank you sir .

ayushwho_
Автор

Thanks man. It confused me a lot before I watched this video.

Shekhar_official
Автор

thanks it was very interesting it really helped me to know something new😏😏😏😏

LostManBagpipe
Автор

Better to never compare floating point numbers utilizing the == operator, just check if the numbers are "close enough" by obtaining their difference and checking if it is smaller than an 'epsilon'.

pfever
Автор

C++ Essentials Part 1 :: Summary Test please honey

karitingmocok
Автор

If I put tha value float a=0.8
And if(0.8==a)
Printf("2")
Else
Print ("3")
And result is
3 why

altmashquraishi
Автор

*_ Dude Help store a float variable inside if else in c _* #ManishSitoula.

ManishSitoula
join shbcf.ru