Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

comparision of floating value

Status
Not open for further replies.

prasannabalaji

Newbie level 6
Joined
Dec 19, 2006
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,385
hi,

is it possible to compare floating point values
for example

a=3.14;
if(a>4)
 

Yes, you can mix data types in C, such as adding (or comparing) together an integer and a floating-point value. C generally converts the smaller of the two types into the other.
The expression if (a>4) mixes the variable "a" of type float and the constant "4" of type integer.
 

Warning: it is unsure to perform some comparisions because of roundoff errors.
For instance, the following code can give unexpected results:

b=a/c;
...
if (a==b*c) ...

Regards

Z
 

if its C, you can mix data types, and remember that the smaller data type is automatically converted to the bigger type of the two while mixing...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top