How to get correct number after calculation? For instance, I want 2.2 - 1 equal to 1.2 and not 1.2000000000002. Wanna get exactly correct answer without rounding the number itself and without just simply changing the way of printing the number via print('%1.1f' % number).
            Asked
            
        
        
            Active
            
        
            Viewed 101 times
        
    -1
            
            
        - 
                    2What's wrong with rounding? – Loocid Aug 08 '18 at 08:33
2 Answers
1
            
            
        Since you don't want string formatting, You can do round:
>>> a=2.2
>>> b=1
>>> round(a-b,1)
1.2
>>> 
 
    
    
        U13-Forward
        
- 69,221
- 14
- 89
- 114
- 
                    I told I don't want number rounding. I need exactly correct answer to operate with. – bL1deR Aug 08 '18 at 09:35
 
    