locked
Hey I have a totally embarrasing, probably really simple question... RRS feed

  • Question

  • Why the hell would the next line not work in c# but the next line work?!?!?!? I went to show someone this really simple C to F and vice versa convertor and it only printed out 0???? I was totally embarassed sry but I picked c# cause i thought the example would be easy to understand for them but I guess I should've went with c++ cause that's what i use, and know that would've worked in c++

    result = (((9/5)*number) + 32);

    result = ((1.8*number) + 32);

    Saturday, January 21, 2006 9:50 PM

Answers

  •  TOMDX wrote:

    Why the hell would the next line not work in c# but the next line work?!?!?!? I went to show someone this really simple C to F and vice versa convertor and it only printed out 0???? I was totally embarassed sry but I picked c# cause i thought the example would be easy to understand for them but I guess I should've went with c++ cause that's what i use, and know that would've worked in c++

    result = (((9/5)*number) + 32);

    result = ((1.8*number) + 32);

    You need to do this

    result = (((9.0/5.0)*number) + 32);

    so it gets treated as a double division (instead of an int division)

    Saturday, January 21, 2006 10:40 PM