How to delete/cancel trailing zeros in complex and imaginary numbers?
8 ビュー (過去 30 日間)
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.
回答 (2 件)
Rik 2021 年 5 月 17 日
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