Fixed point arithmetic is done using a set number of decimal places. It can be faster and is more precise than floating-point.

learn more… | top users | synonyms (1)

1
vote
0answers
32 views

Handle decimal in mongodb

I'm trying to find a way to handle decimals in mongodb. Is there any good way and/or should I handle it with a class like this: ...
2
votes
2answers
89 views

Counting significant figures in a number

I decided to make something to count the significant figures in a number to see how easily it could be done, but I think there may have been a better or simpler way. Any advice even just for ...
0
votes
1answer
126 views

Fixed Point Number to String

I recently learned about using fixed point arithmetic on embedded systems without floating point hardware, so I decided to code it. I tried to write in good style, but emphasized speed over style. ...
3
votes
2answers
79 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 ...
1
vote
2answers
167 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
236 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
182 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
257 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 ...
3
votes
2answers
195 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
433 views
4
votes
1answer
90 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 ...
12
votes
3answers
3k views

Is this a good isNaN method?

...
7
votes
2answers
486 views

BigDecimal made simple

Here is my take on (a lighter version of) Java's BigDecimal. I originally wrote this as a replacement for BigDecimal in order to ...
4
votes
1answer
591 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
749 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 ...
7
votes
2answers
158 views

Test if string is numeric

I want to implement the following function: ...