How to return int from floor in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        
        float f1 = -1.1f, f2 = -1.9f, f3 = 1.8f, f4 = 3.14f;
 
        System.out.println((int)Math.floor(f1));
        System.out.println((int)Math.floor(f2));
        System.out.println((int)Math.floor(f3));
        System.out.println((int)Math.floor(f4));
    }
}




/*
run:
 
-2
-2
1
3
 
*/

 



answered Jun 9, 2022 by avibootz

Related questions

1 answer 118 views
1 answer 176 views
176 views asked Jan 7, 2022 by avibootz
1 answer 113 views
2 answers 139 views
139 views asked Jun 9, 2023 by avibootz
2 answers 138 views
138 views asked Jun 9, 2022 by avibootz
...