Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,955 questions

51,897 answers

573 users

How to convert decimal to double in C#

2 Answers

0 votes
using System;

class Program
{
    static void Main() {
        decimal dec1 = 87236.908m;
        decimal dec2 = 0.43071m;
        decimal dec3 = -7612.8702m; 

        double d1 = Decimal.ToDouble(dec1);
        double d2 = Decimal.ToDouble(dec2);
        double d3 = Decimal.ToDouble(dec3);

        Console.WriteLine(d1);
        Console.WriteLine(d2);
        Console.WriteLine(d3);
    }
}




/*
run:

87236.908
0.43071
-7612.8702

*/

 



answered Jun 2, 2023 by avibootz
0 votes
using System;

class Program
{
    static void Main() {
        decimal x = 21672.747m;
        double d = (double) x / 20.0d;

        Console.Write(d);
    }
}




/*
run:

1083.63735

*/

 



answered Jun 2, 2023 by avibootz

Related questions

1 answer 130 views
130 views asked Nov 16, 2021 by avibootz
1 answer 109 views
1 answer 155 views
3 answers 293 views
3 answers 273 views
...