Problem Here is my take on (a lighter version of) Java’s BigDecimal. I originally wrote this as a replacement for […]
Tag: fixed-point
BigDecimal wrapper that ignores zero operands
Problem I want to perform mathematical operations on a range of values, where zeros should be ignored. This means that […]
Java helper function to round a number to the specified number of decimal places
Problem The function I need: Rounds a double to the specified number of decimal places I figured this would be […]
Implementation of arbitrary-precision integer addition
Problem Implementation: string Add(string a,string b) { int maxLen = Math.Max(a.Length,b.Length); a = a.PadLeft(maxLen+1,’0′); b = b.PadLeft(maxLen+1,’0′); int[] arr1 = […]
Divide decimal by range of fractions, and then convert the fraction that is closest to a whole number to a mixed fraction
Problem My program will divide the decimal (11,12,14,…,148) 11,12,14,…,148) leaving me with list of improper fractions that look like this: […]
Convert decimal currency to an integer
Problem I have some code that is used to convert a decimal currency to an integer with precision being a […]