better lightyear formatting

This commit is contained in:
yuni 2024-04-08 04:42:04 +02:00
parent ac9ee34e1f
commit cccef60090

View file

@ -85,9 +85,9 @@ pub fn ring_density(radius: f32) -> f32 {
pub fn readable_distance(distance: f64) -> String {
let abs_distance = distance.abs();
if abs_distance > LIGHTYEAR2METER * 0.001 {
if abs_distance > LIGHTYEAR2METER * 0.01 {
let lightyears = distance / LIGHTYEAR2METER;
return format!("{lightyears:.3}ly");
return format!("{lightyears:.2} ly");
}
if abs_distance >= 1.0e10 {
let gigameters = distance * 1.0e-9;