Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Actually i have two double varibles like as

C#
double ds,ds1;


ds,ds1 stores the values

based on the requirement i mentioned like as

C#
if(ds.Equals(ds1))
{


}


after that my requirement little bit change i.e ds1 is grater than equal to ds

how can u write the this statement. Actually i write equal to ds,ds1

please help me.

thank u.
Posted

C#
if (ds1 >= ds)
{

}


You should go through a book on learning .net basics as a forum isn't the best place to learn how to code from scratch, we can't be answering every little question you have.
 
Share this answer
 
First of all, use operators, not System.Object.Equal:
C#
if (ds > ds1) //
if (ds >= ds1) //
if (ds == ds1) // if this is C# :-)

But be very careful with ==. In most calculations, you should not use this operator. You need to understand that the floating-point types can only provide approximate representation of mathematical real numbers. The equality should only be considered with certain accuracy. For example, you may need to check up if two values are "close enough":
C#
if (System.Abs(ds - ds1) < delta) //
// where delta is some absolute accuracy
In other cases, you need to operate with relative accuracy.

—SA
 
Share this answer
 
v2
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Jun-15 10:06am    
I up-voted the answer; this is a good reference, but I think just a few words explaining how it is related to the inquire's "code" and what are the inquire's problems would be needed. I tried to explain it in Solution 3, please see.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900