Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:11:46+00:00 2026-06-05T08:11:46+00:00

I have a number in actionscript, arrived at via some arbitrary math: var value:Number

  • 0

I have a number in actionscript, arrived at via some arbitrary math:

var value:Number = 45 * (1 - (1 /3));
trace(value);//30.00000000004

Now, I would like to take the ceiling of this number, except in cases where the amount it is greater than the next lower integer is smaller than some epsilon. In the above example, I really want to round to 30, but only in the case where I know I’m getting a rounding error:

Math.ceil(value); //I want 30, but get 31
Math.ceil(30.1);  //In this case, it's reasonable to get 31

Is there an elegant way to truncate a Number in actionscript? Or easily discard any part of the number that is less than some epsilon?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:11:47+00:00Added an answer on June 5, 2026 at 8:11 am
    var value:Number = 45 * (1 - (1 /3));
    trace(value);//30.00000000004
    
    // Play with arbitraryPrecision until you are satisfied with
    // the accuracy of your results
    var arbitraryPrecision:int = 3;
    var fixed:Number = value.toFixed(arbitraryPrecision);
    
    trace(Math.ceil(fixed));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Actionscript you can have global variables like this: var number : Number =
I have a number of .txt files. I would like to concatenate those and
Does Actionscript have a function that would tell me what number the input is
I have a Flash movie which has a number of actionscript 2 functions which
Does Actionscript have a built-in function that accepts a number and can return a
I have a number of polygons which covers some rectangle. Each polygons is associated
I have a number of selects and when they change value I store the
In actionscript 3, I have a user enter a number into a field and
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
I have recently started doing some ActionScript/Flex programming and I am... Surprised... By the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.