Why does AddMilliseconds round the double paramater?

Posted by fearofawhackplanet on Stack Overflow See other posts from Stack Overflow or by fearofawhackplanet
Published on 2010-04-22T10:43:06Z Indexed on 2010/04/22 10:53 UTC
Read the original article Hit count: 189

Filed under:
|
|
DateTime.Now.AddMilliseconds(1.5); // adds 2 milliseconds

What on earth were they thinking here? It strikes me as horrendously bad practice to create a method that takes a double if it doesn't handle fractional values. Why didn't they implement this with a call to AddTicks and handle the fraction properly? Or at least take an int, so it's transparent to callers?

I'm guessing there must be a good reason why they implemented it this way, but I can't think of what it could be. Can anyone offer any insight?

© Stack Overflow or respective owner

Related posts about c#

Related posts about datetime