Biginteger conversion

Joined
2/21/10
Messages
50
Points
18
Hello anyone! Please i need an urgent help and any response from u will be ok even if unuseful.. Thanks in advance

Look i cannot divide 2 BigInteger variables by each other to get a floating point number(float). When i cast it still gives me either 0.0000 or integer number. What should i do?

Thank you
 
As the name suggests, it doesn't work with floating values.
Use java.math.BigDecimal instead.



Code:
package test;

import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) {
		BigDecimal three = BigDecimal.valueOf(3L);
		BigDecimal two = BigDecimal.valueOf(2L);
		BigDecimal result = three.divide(two);
		
		System.out.println(result.floatValue());
	}
}

Printed result: [b]1.5[/b]

I see you are from Georgia. If you speak russian, you may ask java questions here http://rsdn.ru.
 
Sorry guys forgot to tell im using C#,,, i have imported system.numerics. biginteger well. its not a problem
 
Back
Top Bottom