is an inbuilt method in java that translates a long value into a BigDecimal value with a scale of zero.. log(a * 10^b) = log(a) + b * log(10) Basically b+1 is going to be the number of digits in the number, and a will be a value between 0 and 1 which you could compute the logarithm of by using regular double arithmetic.. Or there are mathematical tricks you can use – for instance, logarithms of numbers close to 1 can be computed by a series expansion The function returns only the lower-order 64 bits when the result of the conversion is too big to be represented as a long … They are very different. ... What is the difference between BigDecimal vs Double? The java.math.BigDecimal.longValue() is an in-built function which converts this BigDecimal to a long value. It converts this BigDecimal to a long ; checking for lost information. I agree with Daniel, the lack of operator overloading in Java is a real detriment to BigDecimal and BigInteger. The BigDecimal(String) constructor should always be preferred over BigDecimal(Double) because using BigDecimal(double)is unpredictable due to the inability of the double to represent 0.1 as exact 0.1. This function discards any fractional part of this BigDecimal. Long: row1.myInteger.longValue() Integer: BigDecimal: new BigDecimal(row1.myInteger) Integer: Float: new Float(row1.myInteger) Float: Integer: To do this conversion you need to decide on a rounding methods such as Math.round(), Math.ceil(), Math.floor() and then cast the result to Integer. A signed 16-bit integer with a minimum value of -32,768 and a maximum value of 32,767. byte. long. The java.math.BigDecimal.valueOf(long val). A signed 64-bit integer with a minimum value of -2 63 and a maximum value of 2 63-1. integer. You could decompose it using. BigDecimal max (BigDecimal val): It returns the maximum of this BigDecimal and val. When deciding how to represent numbers (decimal or otherwise) we must first know if we are dealing with approximate or exact numbers. Converts this BigDecimal to a long. Double: BigDecimal: Double is a wrapper class for the Java native double type, a 64-bit floating point number. It allows us, the reuse of frequently used BigDecimal values and hence this “static factory method” is provided in preference to a (long… You can create a BigInt: scala> var b = BigInt(1234567890) b: scala.math ... Unicode character Byte 8-bit signed value Short 16-bit signed value Int 32-bit signed value Long 64-bit signed value Float 32-bit IEEE 754 single precision float Double 64-bit IEEE 754 single precision float . Use the Scala BigInt and BigDecimal classes. Approximations and exact numbers. BigDecimal(long val) converts a long into a BigDecimal. Although I disagree it's big enough to cause me to not to use the classes, I do wish the JRE would account for these two classes in much the same way string concatenation is handled with overloading +. As others have mentioned, [code]Double[/code] is the wrapper class for [code]double[/code] a primitive double-precision (64-bit) floating-point type; whereas [code]BigDecimal[/code] is an arbitrary-precision decimal type. A signed 32-bit integer with a minimum value of -2 31 and a maximum value of 2 31-1. short. BigDecimal(long val, MathContext mc) converts a long into a BigDecimal, with rounding according to the context settings. This conversion is analogous to the narrowing primitive conversion from double to short as defined in The Java™ Language Specification: any fractional part of this BigDecimal will be discarded, and if the resulting "BigInteger" is too big to fit in a long, only the low-order 64 bits are returned. BigDecimal(String val) converts the string representation of a BigDecimal into a BigDecimal. BigDecimal also has constructors that take a long or double but of course this brings us back to dealing with binary approximations.