error de precision en dato float
Publicado por manuel (1 intervención) el 28/06/2013 03:49:37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//ejemplo sencillo para mostrar error
package ejemplo;
import java.io.*;
/**
*
* @author Administrador
*/
public class Ejemplo {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader dato=new BufferedReader(isr);
try
{
float descuento;
float total;
total=200*0.30f;
System.out.println("el total es $"+total);
}
catch(Exception error){}
}
}
run:
el total es $60.000004 ????? "DEBERIA SER 60.00 ó 60.000000 NO --60.000004--"
BUILD SUCCESSFUL (total time: 2 seconds)
Valora esta pregunta


0