Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Basics (Retired) Perfect Integers and Doubles

C# Question

My question is this; b is an integer, c is a double. the video states that any arithmetic operation involving an int and double ends in a double. so int 2 * double 3.5 = double 7.0 but this can not be done without a cast? and now I have another int, int 3 being divided by double 7 with no cast. shouldn't this throw an explicit conversion error and not compile? i entered different answers for the problem but got it wrong each time. does anyone know the solution. Thank you.

1 Answer

Christian Mangeng
Christian Mangeng
15,970 Points

Hi terence,

if at least one of the two numbers is a double, the result will automatically be of type double. This does not require to convert the integer to a double. Therefore, no conversion error will result when dividing an int by a double.