how to print Four decimal digits | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to print Four decimal digits

i want to print xxx.xxxx not xxx.xxxxxxxxx

13th Jul 2016, 12:18 PM
Rimon Magdy
Rimon Magdy - avatar
2 Answers
+ 2
Console.WriteL("{0:F4}", yourNumber); :F4 lets the program know that you want 4 digits after the decimal point (:F5 would mean 5 digits etc)
13th Jul 2016, 2:00 PM
Tomek Cymes
Tomek Cymes - avatar
+ 1
you can also use Math.Round(yourNumber, 4);
14th Jul 2016, 2:14 PM
LetSPlaYRagE23
LetSPlaYRagE23 - avatar