Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to I define a number as a percentage

Posted on 2007-10-09
8
Medium Priority
?
365 Views
Last Modified: 2012-05-05
This seems kind of silly but I can't find anything on it and I'm just a beginner.  I need to perform a simple calculation. Doing the calc is not the problem but I can figure out how to define a value as a percentage.

Total = (value1 + value2) * buyrate;

I just need the value of buyrate to = 3.99% so I can multiply BY a percentage.

0
Comment
Question by:svasilakos
8 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20040899
When you are displaying Total, then just add % sign hardcoded for example.
<%=Total & "%" %>
0
 
LVL 7

Expert Comment

by:Abu Hamdan
ID: 20040916
Variable as percentage is double or float ...
for example

double myNum = 3.99;

0
 
LVL 7

Expert Comment

by:bungHoc
ID: 20040929
double buyRate = 3.99;
Total = (value1 + value2) * buyRate / 100;

I don't think you bother about %.  If you need to display it, just add % after that number.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 total points
ID: 20040953
divide by 100:

Total= (value1+value2) * buyrate / 100;

Where buyrate = 3.99

0
 

Author Comment

by:svasilakos
ID: 20040958
It's not the display that is causing me problem it's how to do the calculation in the code file

Here is a subset from my code

        double buyrate = 3.99;
        double totcommish = 0;
       
        lessbrate = (advamount + feeamount) * buyrate;

advamount  and feeamount are define elsewhere ( these are sums of some data I am retriving from a db). Obviously double buyrate; is wrong becuase I do not want to multiply by 3.99 , I want to multiply by 3.99%.
       
0
 
LVL 7

Expert Comment

by:bungHoc
ID: 20041000
Heh.. that's why Tim and I both proposed divide by 100!
0
 
LVL 7

Expert Comment

by:bungHoc
ID: 20041028
Ok.. just wondering: How come my answer is not accepted ? :D
0
 

Author Comment

by:svasilakos
ID: 20041174
Sorry, all your respones came very quickly. I saw Tim's before I saw your. You guys posted within miliseconds of each other
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month21 days, 1 hour left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question