How to convert double to float in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        double d = 129341.89;
        float f = Convert.ToSingle(d);

        Console.Write(f);
    }
}



/*
run:

129341.9

*/

 



answered Aug 6, 2019 by avibootz

Related questions

1 answer 197 views
197 views asked Jan 10, 2024 by avibootz
1 answer 204 views
204 views asked Mar 17, 2021 by avibootz
1 answer 215 views
215 views asked Mar 17, 2025 by avibootz
...