math in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I perform a math function in C#
example:

int sales = 25
int goal = 225

i want to devide sales by goal so the sale person knows how much of his goal
he's at
 
Hi!

for a precise division, use double-datatype:

double sales = 25;
double goal = 225;

double result = 25/225;

Bye and checkout my page for tutorials and articles for beginners...
 
Hello,

Thank you for posting.

From your post, my understanding on this issue is: Do math function in C#.
If I'm off base, please feel free to let me know.

The point is to set right variables type.

double x = 25;
double y = 225;
double result = (x / y)*100;
Response.Write(result.ToString() + "%");


Since simple calculation doesn't need to using math class, you can do it
directly in your code.


Sincerely,
Justin Huang
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Thread-Topic: math in C#
| thread-index: Acbj/Gb0iHa0Qbk6Tk+TJQf7Xz0c7A==
| X-WBNR-Posting-Host: 66.80.73.10
| From: =?Utf-8?B?aWdvdHlvdXJkb3RuZXQ=?= <[email protected]>
| Subject: math in C#
| Date: Fri, 29 Sep 2006 12:21:02 -0700
| Lines: 8
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:421757
| NNTP-Posting-Host: TK2MSFTNGXA01.phx.gbl 10.40.2.250
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| How can I perform a math function in C#
| example:
|
| int sales = 25
| int goal = 225
|
| i want to devide sales by goal so the sale person knows how much of his
goal
| he's at
|
 
Back
Top