Division result is always zero?
-
MessageBox.Show(Convert.ToString(1/7));
The result is always zero, when it should have been 0.1428571429 Any ideas? --StarCast
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
Cast
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
It means that you should cast other things :)
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
It means that you should cast other things :)
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
I don't get it? :doh: Can you please explain? too much coffee and a lot less sleep :(( --Star
-
MessageBox.Show(Convert.ToString((double)1/7));
My failometer is detecting vast quantities of FAIL! "Its SQL - hardly programming..." (Caslen)
-
Thank you!!!!:thumbsup:
(double)(1/7)
I keep adding the parentheses, something so simple could make you go crazy...but I guess that's coding for you..lol Thanks againYou could also do
MessageBox.Show(Convert.ToString(1.00/7.00));
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
MessageBox.Show(Convert.ToString(1/7));
The result is always zero, when it should have been 0.1428571429 Any ideas? --StarWhat you wrote was, in vague pseudo-code, Convert.ToString( (Integer 1) / (Integer 7) ). In integer math, the only possible answer is a while number. Since the result, 0.1428, would be truncated to the whole number, 0 is what you got.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008