Thanks in advance
Rounding off decimals in ps.
i want round a money (Float) field from 2.26 to 2.50 and 2.23 to 2.00
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 13, 2012, 12:58 AM EDT
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 13, 2012, 12:48 AM EDT
Try
private void Form7_Load(object sender, EventArgs e)
{
float f1 = 2.26f;
float f2 = (float)Math.Round(f1, 1);
MessageBox.Show(f2.ToString());
}
Thanks
Rajesh Kumar128 reputationPosted Jul 13, 2012, 1:00 AM EDT
Thanks for your code,
but it showes out put as 2.3 and i want 2.50
Rajesh Kumar128 reputationPosted Jul 13, 2012, 1:22 AM EDT