Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2010, 09:44 AM   PM User | #1
t-bag
New Coder

 
Join Date: Sep 2010
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
t-bag is an unknown quantity at this point
Rounding up two decimal places

hi guys,

I have the following bit of code:

Code:
  Decimal retCut = rrp * retailerCut;
  Decimal edcut = rrp * edpercentage;
All are of type decimal, and what I'm trying to do is round the number UP to two decimal places.

Currently I get the following:

retCut = 3.145
edCut = .3455

I have tried performing the Math.Round() - (Math.Round(edCut, 2) ) - function on them however it doesn't seem to b working. I inserted a break point in my code and it didn't seem to perform any action at all on these figures.
I'm inserting these figures into a database column of type Decimal(18, 2) so as a result of the figures not rounding up, I am losing cents on every entry. These can build over over time. Can anyone point me in the right direction?
t-bag is offline   Reply With Quote
Old 11-12-2010, 01:53 PM   PM User | #2
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,054
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
Use Decimal.Round to get the correct number.
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Reply

Bookmarks

Tags
asp.net, c-sharp, calculation

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:37 PM.


Advertisement
Log in to turn off these ads.