Ad
Code
Diff
  • def round_decimal(n, m):
        
        scaled_number = n * (10 ** m)
        
        
        rounded_number = round(scaled_number)
        
       
        result = rounded_number / (10 ** m)
        
        return result
    
    • fn round_half_up(n: f64, m: i32) -> f64 {
    • (n * 10f64.powi(m) + 10f64.powi(-10)).round() / 10f64.powi(m)
    • }
    • def round_decimal(n, m):
    • scaled_number = n * (10 ** m)
    • rounded_number = round(scaled_number)
    • result = rounded_number / (10 ** m)
    • return result