You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having some difficulty with achieving the activity in 1.2.2 Display due to the presence of a space between the sign and the imaginary component.
The activity asks to add a fmt::Display implementation for a struct representing a complex number with real and imaginary f64 values with the output:
3.3 + 7.2i
Using "{} {:+}i" would seem like the reasonable approach but this yields 3.3 +7.2i and it is not obvious how I can pad between the sign and imaginary component to get the output specified. As the activity doesn't test complex numbers with a negative imaginary component, some folks might just use "{} + {}i" and move on to the next lesson.
So am I missing something - is there a way to add padding? should I use some conditional statement based on the sign of the imaginary component?
I noticed this change was introduced by PR #1123 where previous to this, there was no space.
Cheers
The text was updated successfully, but these errors were encountered:
I am having some difficulty with achieving the activity in 1.2.2 Display due to the presence of a space between the sign and the imaginary component.
The activity asks to add a
fmt::Display
implementation for a struct representing a complex number with real and imaginaryf64
values with the output:Using
"{} {:+}i"
would seem like the reasonable approach but this yields3.3 +7.2i
and it is not obvious how I can pad between the sign and imaginary component to get the output specified. As the activity doesn't test complex numbers with a negative imaginary component, some folks might just use"{} + {}i"
and move on to the next lesson.So am I missing something - is there a way to add padding? should I use some conditional statement based on the sign of the imaginary component?
I noticed this change was introduced by PR #1123 where previous to this, there was no space.
Cheers
The text was updated successfully, but these errors were encountered: