Bael 6962 convert double to float in java (#14936)
* Commit 1 - Anton Dalagan Code for Evaluation article. Contains Unit tests, domain class, and App main method. * BAEL-6962 - Created unit test, and updated pom.xml * BAEL-6962 - Removed files unrelated to the article * BAEL-6962 - Added a declartions for float and double in diff class. Updated unit tests. * BAEL-6962 - Made changes into the unit tests. Removed printlns, and updated isinstance with assertequals
This commit is contained in:
		
							parent
							
								
									150efcec72
								
							
						
					
					
						commit
						3bd2e7eb3e
					
				| @ -9,25 +9,21 @@ public class FloatDoubleConversionsTest { | |||||||
|     public void whenDoubleType_thenFloatTypeSuccess(){ |     public void whenDoubleType_thenFloatTypeSuccess(){ | ||||||
|         double interestRatesYearly = 13.333333333333334; |         double interestRatesYearly = 13.333333333333334; | ||||||
|         float interest = (float) interestRatesYearly; |         float interest = (float) interestRatesYearly; | ||||||
|         System.out.println(interest);  //13.333333 |         Assert.assertEquals(13.333333f, interest, 0.000004f); | ||||||
|         Assert.assertTrue(Float.class.isInstance(interest));//true |  | ||||||
| 
 | 
 | ||||||
|         Double monthlyRates = 2.111111111111112; |         Double monthlyRates = 2.111111111111112; | ||||||
|         float rates = monthlyRates.floatValue(); |         float rates = monthlyRates.floatValue(); | ||||||
|         System.out.println(rates);  //2.1111112 |         Assert.assertEquals(2.1111112f, rates, 0.00000013); | ||||||
|         Assert.assertTrue(Float.class.isInstance(rates));//true |  | ||||||
|     } |     } | ||||||
|     @Test |     @Test | ||||||
|     public void whenFloatType_thenDoubleTypeSuccess(){ |     public void whenFloatType_thenDoubleTypeSuccess(){ | ||||||
|         float gradeAverage =2.05f; |         float gradeAverage =2.05f; | ||||||
|         double average = gradeAverage; |         double average = gradeAverage; | ||||||
|         System.out.println(average);  //2.049999952316284 |         Assert.assertEquals(2.05, average, 0.06); | ||||||
|         Assert.assertTrue(Double.class.isInstance(average));//true |  | ||||||
| 
 | 
 | ||||||
|         Float monthlyRates = 2.1111112f; |         Float monthlyRates = 2.1111112f; | ||||||
|         Double rates = monthlyRates.doubleValue(); |         Double rates = monthlyRates.doubleValue(); | ||||||
|         System.out.println(rates);  //2.1111112 |         Assert.assertEquals(2.11111112, rates, 0.0000002);//true | ||||||
|         Assert.assertTrue(Double.class.isInstance(rates));//true |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user