Fixed point arithmetic is done using a set number of decimal places. It can be faster and is more precise than floating-point.
3
votes
2answers
57 views
BigDecimal wrapper that ignores zero operands
I want to perform mathematical operations on a range of values, where zeros should be ignored. This means that multiplication by zero does not result in zero but returns the first operand and likewise ...
12
votes
3answers
2k views
1
vote
2answers
90 views
Rounding prices
I have written a PHP function that should round prices to a desired format.
E.G. 1547.86456
That should be : 1547.85
OR
if desired : 1547.86
The code has been written and it works under several ...
2
votes
2answers
135 views
Decimal expansion of a rational number
I wrote a program that does division and either does or doesn't show repeating groups. After designing it the first time I had to redesign it because although it worked it was unnecessarily complex. ...
4
votes
2answers
100 views
Storing currency-precision values
I'm trying to develop a program that stores currency values. In my particular application I only care about two decimal of precision (cents) but have read it's a good idea (for accuracy when dealing ...
4
votes
2answers
107 views
Java helper function to round a number to the specified number of decimal places
The function I need:
Rounds a double to the specified number of decimal places
I figured this would be a part of java.lang.math, but inexplicably it doesn't ...
7
votes
2answers
136 views
3
votes
2answers
80 views
Cut float numbers in a stream (putchar, getchar) and in a string
For example, the following row:
"a+12.3456-b-0.456789+1.3-45678"
will be transformed into
"a+12.34-b-0.45+1.3-45678"
That is, we need to cut out the figures after the point from the third figure. ...
3
votes
3answers
311 views
4
votes
1answer
80 views
BigDecimal made Simple - take 2
Following all comments on my original post:
BigDecimal made Simple
The following interface was derived from functionality provided by (mainly) Bigdecimal and is ...
5
votes
2answers
371 views
BigDecimal made Simple
Here is my take on (lighter version of) Java's BigDecimal.
Originally I wrote this as a replacement for BigDecimal in order to improve performance during serialisation and data manipulation.
...
4
votes
1answer
369 views
Followup: How do I optimize this Java cube root function for BigInteger?
Followup to How do I optimize this Java cube root function for BigInteger?
So I've tried several implementations of this algorithm. The version using only BigInteger sometimes results in a ...
7
votes
1answer
437 views
How do I optimize this Java cube root function for BigInteger?
I find that this function is one of the biggest causes of slow program execution. I can write a square root version with BigInteger only, but with the cube root, the algorithm sometimes gets caught in ...