Aggiunto test somma double
Test dell'affermazione: 1/1000 + 1/1000 .... per 1000 volte non fa 1 in floating point
This commit is contained in:
		
							
								
								
									
										12
									
								
								Test somma floating point/FPSum.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								Test somma floating point/FPSum.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | public class FPSum { | ||||||
|  |     public static void main(String[] args) { | ||||||
|  |         double sum = 0; | ||||||
|  |          | ||||||
|  |         for(int i = 0; i < 1000; i++) { | ||||||
|  |             sum += 1/(double)1000; | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         System.out.println("Numero teorico: 1"); | ||||||
|  |         System.out.println("Numero reale: " + sum); | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user