Rounding to 2dp
              in 
             Programming Questions 
              •  
              2 years ago    
            
 
           
             hey, I've been stuck on this for ages on this simple issue
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
 
            
           
             basically I have a float called "D" and i need it to be rounded to 2dp
            
            
             I originally made this in excel in my spare time at work, now I'm having issues with making it in processing
            
            
             -I'm taking minutes and seconds (mm:ss) with seconds as a decimal
            
            
             -then I'm flooring to remove the seconds
            
            
             -then multiplying the seconds by 1.66 to make it a decimal (ie. 30 seconds will be represented as 0.5)
            
            
             -this was working in excel but in processing 30 seconds is represented as 0.498
            
            
             -I was using round(Val, 2) in excel but I can't in processing (unless there's a library :) )
            
            
             it seems obvious that by rounding to 2dp it'll fix my issue but I can't seem to make it work
            
            
             have also tried to Val = round(D*100)/100 but haven't had any luck
            
            
             any help would be greatly appreciated
            
 
            
              
              1  
            
 
            