Skip to main content

usage_percent

Function usage_percent 

Source
pub fn usage_percent(used: u64, total: u64) -> f64
Expand description

Compute usage percentage from used/total byte counts.

Returns 0.0 if total is 0 (avoids divide-by-zero).

ยงExamples

use batuta_common::math::usage_percent;
assert!((usage_percent(750, 1000) - 75.0).abs() < 1e-10);
assert_eq!(usage_percent(0, 0), 0.0);
assert!((usage_percent(1024, 4096) - 25.0).abs() < 1e-10);