Questions tagged [fixed-point]
Fixed point arithmetic is done using a set number of decimal places. It can be faster and is more precise than floating-point.
32 questions
4
votes
2
answers
741
views
Fixed Point Type
I am implementing a fixed point type, which mostly is used to be able store numbers as multiples of some base (power of 2). Apart from that, the type should be able to replace double/float values ...
0
votes
3
answers
334
views
Fractional binary number to decimal number
Write and test your own double abc (char * b) function in the program, taking in the form of a string the fractional binary number of the form "1101.101" ...
4
votes
0
answers
826
views
Java code to convert BigDecimal to/from .NET decimal
Background
In many languages we have built-in data types for representing decimal floating point numbers. In .NET that's decimal, and in Java we have ...
7
votes
2
answers
355
views
Method for formatting a decimal number in Python using the given maximum number of digits and decimal places
The question itself should be fairly self-explanatory. My method takes in value, max_digits, and ...
3
votes
2
answers
1k
views
Adding thousand separator to various number types
Am making a pure .net library with helper functions (GitHub).
However I wanted to have a thousand separator for all number types and here is what I am currently doing
...
1
vote
2
answers
228
views
Converting a String to USD
I'm working on a clientside iOS app for my school that involves students purchasing things, and I wrote a String extension for formatting a ...
4
votes
1
answer
212
views
Enforcing numeric inputs and sanitizing different formats for IE11 input fields
I'm working on a web form that functions with numeric inputs. I have <input type="number"> input fields and with Chrome and Firefox things work nicely since ...
4
votes
4
answers
5k
views
Convert decimal to string
I wrote a C# program that converts decimal to string. It is not the best but it works. I'm looking for inputs from others on how ...
1
vote
1
answer
2k
views
Convert decimal currency to an integer
I have some code that is used to convert a decimal currency to an integer with precision being a function of which currency is being converted.
This code is more of a "brute-force" method to do the ...
4
votes
3
answers
560
views
Formatting the opposite of some numbers, with decimal alignment
Background
I have a list of strings containing numbers. Each string is 8 characters long. For example :
...
7
votes
2
answers
2k
views
Fixed Point Arithmetics in C++ using templates
I am trying to create a Fixed Point Arithmetics library : I call fixed point a number which has bits reserved for decimal part.
Here is the code :
...
7
votes
2
answers
398
views
Calculating a ton of mathematical constants
For a while now I have been working to construct a program to calculate a lot of mathematical constants. Before I explain, here's the code:
Code
...
3
votes
1
answer
881
views
Indian numbering system formatting
The following code converts a number into Indian numbering system format.
I know locale can also help in getting similar format but I wanted something that can work on any system because not all ...
8
votes
3
answers
2k
views
String formatting for uint64_t that represents a fixed-point decimal
My goal is to take a uint64_t that represents a fixed-point decimal, and output a string representation of the decimal. The fixed-point representation always has ...
3
votes
3
answers
378
views
Java number formatting in accountant style
I have written a string number formatter. I would like to know if this can be improved and any suggestions with how it's done.
The purpose of this function is to convert a double that has been ...