“Possible loss of precision” in my Java program

后端 未结 5 1267
北荒
北荒 2021-01-03 03:03

I\'m new to Java. I wrote the following code:

import java.io.*;
import java.lang.*;

public class distravel
{
    public static void main(String args[])
             


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 03:39

    Don't use floats in your floating point math calculations unless you have a specific reason for doing so (you don't). The overhead for the preferred type, double, is not much higher and the benefit in accuracy is great.

提交回复
热议问题