• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

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.



C++:
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