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 147595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:48:32+00:00 2026-05-11T08:48:32+00:00

I have BigDecimal objects serialized with BlazeDS to Actionscript. Once they hit Actionscript as

  • 0

I have BigDecimal objects serialized with BlazeDS to Actionscript. Once they hit Actionscript as Number objects, they have values like:

140475.32 turns into 140475.31999999999998

How do I deal with this? The problem is that if I use a NumberFormatter with precision of 2, then the value is truncated to 140475.31. Any ideas?

  • 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. 2026-05-11T08:48:33+00:00Added an answer on May 11, 2026 at 8:48 am

    This is my generic solution for the problem (I have blogged about this here):

    var toFixed:Function = function(number:Number, factor:int) {   return Math.round(number * factor)/factor; } 

    For example:

    trace(toFixed(0.12345678, 10)); //0.1 
    • Multiply 0.12345678 by 10; that gives us 1.2345678.
    • When we round 1.2345678, we get 1.0,
    • and finally, 1.0 divided by 10 equals 0.1.

    Another example:

    trace(toFixed(1.7302394309234435, 10000)); //1.7302 
    • Multiply 1.7302394309234435 by 10000; that gives us 17302.394309234435.
    • When we round 17302.394309234435 we get 17302,
    • and finally, 17302 divided by 10000 equals 1.7302.

    Edit

    Based on the anonymous answer below, there is a nice simplification for the parameter on the method that makes the precision much more intuitive. e.g:

    var setPrecision:Function = function(number:Number, precision:int) {  precision = Math.pow(10, precision);  return Math.round(number * precision)/precision; }  var number:Number = 10.98813311; trace(setPrecision(number,1)); //Result is 10.9 trace(setPrecision(number,2)); //Result is 10.98 trace(setPrecision(number,3)); //Result is 10.988 and so on 

    N.B. I added this here just in case anyone sees this as the answer and doesn’t scroll down…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 103k
  • Answers 103k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a couple of issues with your raw string… May 11, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer Hey Joel - the web deployment project is a bit… May 11, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer You can use CoreGraphics to create a path for a… May 11, 2026 at 8:23 pm

Related Questions

I am working on a basic Struts based application that is experience major spikes
I need a table to store the state of a financial transaction. The state
I have a BigDecimal calculation result which I need to round to the nearest
Currently i have this method: static boolean checkDecimalPlaces(double d, int decimalPlaces){ if (d==0) return

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.