I have got an input textbox, to seize a number of seconds.
I seize 180,095 in it, with French format, that makes 180.095 in American format.
I use it with such code :
float floatSec = float.Parse(txbSource.Text); int nbSec = (int)Math.Floor((double)floatSec); int nbMilli = (int)(floatSec - Math.Floor((floatSec - nbSec) * 1000)); TimeSpan ts = new TimeSpan(0, 0, nbSec, nbMilli);
Well, for floatSec I wait 180.095, and that is what it is.
For nbSec I wait 180, and that is what it is.
Well now, I want to obtain the number of milliseconds, so I subtract nbSec from floatSec, and after multiplying by 1000 I wait 95, right ?
Well, I obtain 85.
For sure a problem of rounding, I remember having seen that somewhere.
What do you propose as best solution to treat this ?