How to delete/cancel trailing zeros in complex and imaginary numbers?
7 vues (au cours des 30 derniers jours)
Whenever I use or create imaginary and complex numbers, they are always saved with trailing zeros, for example 1.22000000 + 2.150000000i . I want to mimic the behaviour and structure of fixed-point while still being in floating-point. I want 1.22 + 2.15i. How do I delete or cancel the trailing zeros? I have tried different ways and as soon as the imaginary unit is present, the zeros come back.
Rik le 17 Mai 2021
The way data is stored and the way it is displayed is not necessarilly connected. You can influence the way data is presented with the format function. If you want more control, you need the fprintf or sprintf functions.
1.22 + 2.15i