[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Negative Decimal

Posted on 2012-03-18
9
Medium Priority
?
414 Views
Last Modified: 2012-03-21
I am tired of beating my head up against the desk. I've been trying to convert a positive decimal to a negative without the value calculating as a negative value. Math.Abs does half the job and I have no clue on how to convert.

Any help would be nice.

Thanks
0
Comment
Question by:mBenton1979
9 Comments
 
LVL 16

Expert Comment

by:Stephan
ID: 37736138
Are you looking for this:

decimal.Negate
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 37736542
> convert a positive decimal to a negative without the value calculating as a negative

So a negative should be positive??
Could you please provide an example?

/gustav
0
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 300 total points
ID: 37737509
The requirement is to convert Postive to Negative. But Math.Abs would convert Negative to Postive. Confusing.. What is the correct requirement?
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 52

Expert Comment

by:Gustav Brock
ID: 37737664
OK. Back to school. Remember your pencil and the apple for the teacher.

Given: p = 1.11
Wanted: n = -1.11
Solution: n = -p

Or?

/gustav
0
 

Author Comment

by:mBenton1979
ID: 37737682
is here is a portion of my test code. I'm looking at the food, liquor, and beer to display negative values without them adding or subtracting as such. If this doesn't work Ill just have to validate the fields and force the negative and tweak my code

 decimal food = System.Decimal.Parse(foodOperand.Text);
            decimal liquor = System.Decimal.Parse(liquorOperand.Text);
            decimal beer = System.Decimal.Parse(beerOperand.Text);

            decimal calculatedDeductions = subtractExpend(food, liquor, beer);
            textBox2.Text = calculatedDeductions.ToString();


private decimal subtractExpend(decimal food, decimal liquor, decimal beer)
        {
            return food + liquor + beer;
        }
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 37737707
I see no negatives here.

> ..  without them adding or subtracting as such.

That means doing nothing. So what to do?
Perhaps if you provide an example, we can understand the issue.

/gustav
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 37747273
??

A solution to nothing?

/gustav
0
 

Author Comment

by:mBenton1979
ID: 37747299
Oh snap I awarded the wrong person!! Guess no take backs huh?
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 37747415
Oh, that explains.

No problem for me though, I'm not in it for the monye - just curious what the problem really was and what the solution might be?

/gustav
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month18 days, 21 hours left to enroll

834 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