Calculate & subtract percentage in C# [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Well I know this would be a very easy question ,but i am poor at this concept of Maths.
I know what my final answer should be ,but this answer should come after I subtract some specific percentage from another amount. I want to know what that another amount should be.
Making it a bit simpler :
this is my equation : x - 12% of x should result in 250$. I need to find x.
( Please know if I add 12% to 250 , it will be wrong as 12% of 250 would be different from 12% of what that another amount would be ).
Thank you friends.

This is simply algebra (not necessarily even relevant to C#).
Your equation is:
Solve for :
Therefore this can be calculated in C#:
double x = 250/0.88;
Console.WriteLine(x);
which outputs 284.090909090909

Related

How to calculate a logical curve along a set of values? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am trying to take a float value, with an arbitrary minimum and maximum possible value, and convert it to a linear scale, for representation on a bar-shaped indicator. The problem is, I can't just lerp it between the minimum and maximum, because the maximum value will always be dramatically higher than the minimum value. I have an array of arbitrary values that I want to act as intermediate points between the minimum and maximum. Now I just need to calculate a logical best-fit curve through the points. Each value is always larger than the last, and the rate of increase in value accelerates the further up you go, but there is no simple formula for calculating this rate of acceleration.
Here's an example of the values that may be used:
6.0, 13.5, 30.0, 75.0, 375.0
where 6 is the minimum, and 375 is the maximum.
If x is exactly one of these values, I would want a simple value depending on how many total values there are, I.E 0, 0.25, 0.5, 0.75, 1. The issue is calculating the in-between values.
How would I go about achieving this? I apologize if a question like this has already been asked, as it feels like a common problem, although I didn't know what to search for. If this has already been answered before, please just point me in the right direction.
Reposting my comment as an answer, as requested.
If a curve might be y(x) = k^(ax+b), take logs of both sides and you have a linear relation. As pointed out tho, this is maths not programming.
I’d pick k = 2, e or 10 for easier implementation; a & b you work out from data.

How Math.Round is working? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Recently I found an issue with C# Math.Round that makes me confused:
Math.Round(1.125, 2) == 1.12
However:
Math.Round(1.115, 2) == 1.12
Also
Math.Round(1.225, 2) == 1.23
And
Math.Round(1.215, 2) == 1.22
The last three samples are make sense just want to know how does it work for the first one?
Regarding to the document, if round to nearest even number then why in third sample round to Odd number?
Is anyone has any idea how is rounding the digits?
Updating
As I put the link, I know try to round to nearest even number, I want to know how implementing it (Using shift bytes)?
In the last three examples, it's working as documented. In the first case though, it appears to go wrong:
Math.Round(1.125, 2) == 1.12 // Would expect 1.13
The reason is simple: floats are stored as binary values; not decimal. So it's rounding the binary value that 1.125 has been converted to. In this case it is slightly below 1.125 and thus rounds "the wrong way".

Regarding logical equation on my C programming [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a situation on my C programming here and just wondering whether my solution is the correct way:
I have a LED display with particle count sensor and will show 6 digit of seven segment numbers as the count value. The sensor will give voltage input value. The input is from 0V to 10V. So the range of 0V-10V need to be shown in the display as 000000 to 999999 count.
My solution is:
Display number = Input voltage * 99999.9
For example:
Display number = 10.000*99999.9=999999
Display number = 5.500*99999.9=549999
Display number = 2.300*99999.9=229999
Is this the correct solution? I notice that I will get a lot of 9 on the display value.
The most usable and user friendly solution is to ignore the fact that your most significant digit is capable of displaying up to 9 and simply multiply by 10000 unless you desperately need the maxim resolution in which case simply use a scale factor of 100000 and document that your range is 0-9.99999.
My reasoning is that it is better to either loose one digit in the accuracy across the whole range or clip just the maximum value than to have an error across the entire range.

Rewrite an even number as 2^a * b [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I'm looking for an algoritm that takes an even number bigger than 2, and rewrite it as (2 to the power a) times b, with a and b being calculated by the algoritm and b being an odd number.
If x is the input number, divide x by two. If the new number is even, repeat the process, until the outcome is odd. This odd number is b in your formula, while a is the number of iterations you just performed.
Now that you have an idea on the algorithm, try coding it. StackOverflow will not do this for you.

What are the correct names of unit interpolations and how to implement them? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I can't find for the life of me the correct names for interpolations like the ones below.
I am trying to look them up google using ease-in interpolation, types of interpolation, but without much luck.
All I want is to implement them in a fashion like this:
double Interp ( double value, double t )
where value is the value to be interpolated and t is the time value that can be any value between 0-1, including 0 and 1.
So if Interp was using a linear interpolation and value was 10, and t was 0.5, the return would be 5. But I want to get the values using other interpolations.
Any help on this?
I remember seeing a website with flash animations showing the formula of each one time but can't find it anymore.
I've heard this referred to as "easing" or "tweening".
http://robertpenner.com/easing/ has a Flash demo and links to a PDF file with the equations.
http://code.google.com/p/tweener/ has an ActionScript library to implement them, with links to ports in JavaScript, Python, C++, etc.
http://gsgd.co.uk/sandbox/jquery/easing/ is an easing plugin for jQuery.
Interpolation involves estimating a curve based on a set of inputs, the larger the set of inputs the better the curve estimation. Is this what you are trying to do here? This guys talks about linear and quadratic interpolation techniques. http://www.codeproject.com/KB/recipes/simple_interpolation.aspx. If you want some more specialised interpolation techniques we really need to know a little more about the shape of the curve you are trying to estimate
See: http://mathworld.wolfram.com/Interpolation.html

Categories