User Tag List

Results 1 to 2 of 2

Thread: Rounding decimals?

  1. #1
    No Products Registered

    Join Date
    Oct 2006
    Location
    USA
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rounding decimals?

    I've been tasked with revising my stores offline point of sale program. Our servers go down regularly, and we need an efficient way to log our transactions offline.

    Here's the point: How do I get Fusion 2 (regular edition) to round the change? The C++ book I've got recommends making pennies integers, but man that's a lot of work for edit boxes in Fusion. Correct me if I'm wrong!

    This is what I've got so far (I know it's convoluted, I'm hoping it's easier than this). Tax is editable as we have stores in different states, and the "floor" is to cut off superfluous floating points.

    Floor(((value( "subtotalnum" )*(Val(Edittext$( "tax" ))/1000.0))+Round(value( "subtotalnum" )))*100)/100

    It works fine...if the price of a product ends in ".99", otherwise it's a crapshoot. Is there some function or formula I'm missing? I've searched these forums, and the internet in general and have found little help. Any input is greatly appreciated.

  2. #2
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Rounding decimals?

    Do you mean to round to whole pounds, or round to whole pennies?

    For pennies, I'd expect the following to work:
    store (round((1.0+Val(Edittext$( "tax" )/1000.0)*Round(value( "subtotalnum")*100)) as pennies
    Set editbox to str$(floor(pennies/100)) + "." + Left$("00",1-Floor(log(pennies mod 100))) + str$(pennies mod 100)

    That should construct the number manually, even putting in the extra 0 if pennies is under 10, so you don't get the long decimals from floating point inaccuracies.

    I don't have MMF to hand so it might be log10() or log(... , 10) instead of log().

    EDIT: oops, it was only adding the 0 if there was more than 10 pennies, try now.

    Note: I don't think it likes negative number.

Similar Threads

  1. Rounding issues
    By Arnax in forum Android Export Module Version 2.0
    Replies: 1
    Last Post: 24th February 2012, 08:17 AM
  2. Rounding Down Counters
    By etrose in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 13th November 2011, 09:41 PM
  3. Rounding Down
    By etrose in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 7th November 2011, 11:32 AM
  4. Rounding Values up or down
    By Mantoid in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 18th June 2008, 07:11 PM
  5. Rounding up/down
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 17th June 2007, 11:43 AM

Posting Permissions

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