Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding decimal value
Message
De
29/05/2011 11:22:37
 
 
À
29/05/2011 10:58:15
Vishal Nyamagoudar
Swift Infocom India Pvt Ltd
Inde
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01512198
Message ID:
01512202
Vues:
46
>Hello Everyone,
>
>Code is in C#.net
>
>double a,b,ans;
>a=3;
>b=2;
>ans=a/b;
>
>ans will be 1.5 dcimal value
>
>i want to check returned answer is decimal value or integer value
>
>like if ans is 1.5 then decimal
>
> if ans is 2 then it should return integr value
>
>How cal i find out returned answer is integer or decimal value..!!!!
>
>Thanks...

Since ans is declared as double it will still be double whether it is 1.5 or 2.0

You can check whether it has it has anything after the decimal point
bool isIntegerValue = ( ans % 1.0) == 0.0
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform