Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2010
    Thanked 0 Times in 0 Posts

    Rounding up two decimal places

    hi guys,

    I have the following bit of 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?

  2. #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Thanked 29 Times in 29 Posts
    Use Decimal.Round to get the correct number.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts