Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 5 of 5

Thread: Incorrect math?

  1. #1
    Join Date
    Dec 2003
    Location
    Raleigh, NC
    Posts
    80

    Incorrect math?

    I am writing an app in which I'm trying to convert any # of seconds to minutes + seconds. When I tried to convert 55555.365 seconds, the result I got was 925 minutes and 55.3649999 seconds. The code I used is:
    if Sec >= 60 then
    NewNum = Sec / 60;
    Min1 = Math.Floor(NewNum);
    Expanded = Min1 * 60;
    Sec1 = Sec - Expanded;
    end
    In 2 paragraph objects, I display Min1 and Sec1.
    This works correctly if I enter 55.365, 555.365, or even 5555.365. However, entering 55555.365 gives the erroneous result. In the format XXXXX.365, I didn't encounter any problems until XXXXX got to be 32800 or higher, at which point the "9999" stuff started appearing. Ugh!

  2. #2
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Still I don’t quite understand how numbers are stored inside the computer but if you use the solution from your previous thread , just adding
    Code:
    Sec1 = Math.Round(Sec1, 10);	-- round with the highest available precision
    you’ll have the result 925 min 55.365 sec.

  3. #3
    Join Date
    Dec 2003
    Location
    Raleigh, NC
    Posts
    80

    Math works

    Csd to the rescue once again! After midnite, I didn't recall that the newest release of AMS5 had the precision in the Math.Round function, but in the light of day, your msg hit me in the forehead with a bonk. Of course, it works like a charm. Thanks for the refresher!

  4. #4
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Just a pleasure! There are a lot of forum posts about Flash and Videos; stuff I’m not familiar with. I grasp the opportunity when I see an issue I “understand” (the decimal portion is a bit tricky). I have worked with figures and people, people and figures, all my life…

  5. #5
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Csd to the rescue once again!
    Nice one csd214.

Similar Threads

  1. A project for all you math whizzes
    By Corey in forum AutoPlay Media Studio 5.0
    Replies: 13
    Last Post: 02-12-2005, 04:45 AM
  2. Program for doing simple math problems
    By Zippo in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 12-30-2004, 08:52 AM
  3. After buliding project, the location seem is incorrect!
    By pierre in forum AutoPlay Media Studio 5.0
    Replies: 5
    Last Post: 04-23-2004, 08:17 AM
  4. Math Error
    By eric_darling in forum AutoPlay Media Studio 5.0
    Replies: 9
    Last Post: 11-16-2003, 12:31 AM
  5. Math Calculations
    By Incrocci in forum AutoPlay Media Studio 4.0
    Replies: 4
    Last Post: 07-31-2003, 01:19 PM

Posting Permissions

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