+ 1
quadratic equation
public class Program { public static void main(String[] args) { float a = 1.0f ; float b = 2.0f ; float c = -3.0f ; float x =(float) (-b + Math.sqrt((b*b)-(4*a*c)))/(2*a); System.out.println(x); float y = (float) (-b - Math.sqrt((b*b)-(4*a*c)))/(2*a); System.out.println(y); } } QUESTION: 1. Why do we need include f (ex. 1.0f) in the initialization? 2. why do we need to mention float in the brackets in the formula statement?
3 odpowiedzi
+ 2
thank you
+ 1
thanks @gordie
0
but we initialised "a" as a float why we need to add f after 1.0?