mercredi 15 avril 2020

How to use std::ratio for values larger than int64_t?

I want to encode solar mass as a std::ratio (in order to convert it to kg). How can I do such a thing if solar mass is 1.988478e+30 kg?

std::ratio<(unsigned long long)1'988'478e+39, 1> kg_to_solar_mass // overflow

Aucun commentaire:

Enregistrer un commentaire