c# - Get Percentage of Width -


i have been looking through answers on here , know similar other questions have tried gives me incorrect result. drawing graph in c#. have width seen below.

public const int image_height = 1920;    //canvas heigh public const int image_width = 1080;     //canvas width public const int borehole_rect_width = (image_width / 2 - (10 * margin)); 

the important value borehole_rect_width returns 240. trying work out 15 percent of value. have checked on website below , others , 15 percent of 240 36.

percentage calculator

however when use code below result of 6 not seem correct me.

 int percent = (int)math.round((double)(100 * 15) / (double)borehole_rect_width); 

i not sure im doing wrong appreciated.

te 15 percent of somethin need multiply 0.15. instance

var percent = value * 0.15; // if value == 240 thant percent 36 

or can write method able percentage want example:

public double percentof(double percent, double number) {     return number * (percent / 100); } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -