I am trying to get a string with a number (double) formatted with 2 decimals… If i use interpolation I get the following
A = 3.14256789
c = “The letter is $A”
c is then “The letter is 3.14256789”…
What I am looking for is “The letter is 3.14”.
If I use the printf package I can print what I am looking for, but not able to store it as variable. @printf(“the letter is %.2f”, A)
I usually just use round(A, digits = 2) for this (or round(A, RoundDown, digits = 2) if you want to cut off the remaning digits rather than round up if the third digit is >= 0.5)