What is the difference between Math.Floor() and Math.Truncate() in .NET? e.g. Math.Floor(5.4) = 5 Math.Truncate(5.4) = 5 – subramani
19239
What is the difference between  and  in .NET?
82915
For example, the standard division symbol '/' rounds to zero:  &gt;&gt;&gt; 4 / 100 0   However, I want it to return 0.04. What do I use?
81909
What is the difference between ref and out parameters in .NET? What are the situations where one can be more useful than the other? What would be a code snippet where one can be used and another can't?
62739
I am trying to write the Euclidean algorithm in the following way:  $A = \lfloor A \div B \rfloor \times B + (\text{remainder of}) \: A \div B $   Now is there any symbol I can use  to say "remainder of A $\div$ B"? I know that in the C programming language there is the operator % for modulus; is that a valid symbol in maths? Can I write A % B? Or is there some other way?
32185
I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding.  For example:  declare @value decimal(18,2)  set @value = 123.456   This will automatically round @value to be 123.46, which is good in most cases.  However, for this project, I don't need that.  Is there a simple way to truncate the decimals I don't need?  I know I can use the left() function and convert back to a decimal.  Are there any other ways?
29396
I'm wondering whether there is a difference between these two expressions. I never know which one to use. Google seems to return the same amount of results for both, so I suppose there might be a difference.        What are the alternatives for this project?     What are the alternatives to this project?
56109
I'm curious as to whether or not there is a real difference between the money datatype and something like decimal(19,4) (which is what money uses internally, I believe).  I'm aware that money is specific to SQL Server. I want to know if there is a compelling reason to choose one over the other; most SQL Server samples (e.g. the AdventureWorks database) use money and not decimal for things like price information.    Should I just continue to use the money datatype, or is there a benefit to using decimal instead? Money is fewer characters to type, but that's not a valid reason :)
85430
Here's a silly fun question:  Let's say we have to perform a simple operation where we need half of the value of a variable. There are typically two ways of doing this:  y = x / 2.0; // or... y = x * 0.5;   Assuming we're using the standard operators provided with the language, which one has better performance?  I'm guessing multiplication is typically better so I try to stick to that when I code, but I would like to confirm this.   Although personally I'm interested in the answer for Python 2.4-2.5, feel free to also post an answer for other languages! And if you'd like, feel free to post other fancier ways (like using bitwise shift operators) as well.
71878
In class, we briefly covered what "floor" and "ceiling" mean.  Very simple concepts.  They were on one slide, and then we never heard about them again.  But now the following homework problem has popped up:  $$\lfloor\lfloor x/2 \rfloor / 2 \rfloor = \lfloor x/4 \rfloor$$  Usually when I post a problem (especially from homework), I like to demonstrate that I'm not just asking for the answer by showing what I've done, what I know so far, and so on... but in this case, I have absolutely no idea where to even begin.  I will say that my first approach was to create a chart and try various values for "x" in order to see if there's a pattern and to make sure there was no easy counter-example to prove it false.  That was all fine and well, but ultimately I couldn't figure out what to do with the results.  Googling for this is quite difficult, as everyone uses slightly different notation and therefore one search doesn't encompass all the actual results.  The only clue that I've seen so far that kind of sort of makes sense, was when some guy said that "x" should be replaced with "4n + k", since the right-hand side of the equation is divided by 4, so that k is any remainder 0 through 3.  How should one approach this problem?  What kind of manipulations can you do to floors?  What can you assume?  etc. etc. ...
2846
Why does the following behave unexpectedly in Python?  &gt;&gt;&gt; a = 256 &gt;&gt;&gt; b = 256 &gt;&gt;&gt; a is b True           # This is an expected result &gt;&gt;&gt; a = 257 &gt;&gt;&gt; b = 257 &gt;&gt;&gt; a is b False          # What happened here? Why is this False? &gt;&gt;&gt; 257 is 257 True           # Yet the literal numbers compare properly   I am using Python 2.5.2. Trying some different versions of Python, it appears that Python 2.3.3 shows the above behaviour between 99 and 100.  Based on the above, I can hypothesize that Python is internally implemented such that "small" integers are stored in a different way than larger integers and the is operator can tell the difference. Why the leaky abstraction? What is a better way of comparing two arbitrary objects to see whether they are the same when I don't know in advance whether they are numbers or not?
6852
What is the difference between below variables assignments?   var=23 var =23 var= 23 var = 23   Is there any difference in space around the assignment operator?
75648
I am trying to get a greater understanding on the differences between the DELETE and TRUNCATE commands. My understanding of the internals goes something along the lines of:  DELETE -> the database engine finds and removes the row from the relevant data pages and all index pages where the row is entered. Thus, the more indexes the longer the delete takes.  TRUNCATE -> simply removes all the table's data pages en mass making this a more efficient option for deleting the contents of a table.  Assuming the above is correct (please correct me if not):   How do different recovery modes affect each statement? If there is any effect at all When deleting, are all indexes scanned or only those where the row is? I would assume all indexes are scanned (and not seeked?) How are the commands replicated? Is the SQL command sent and processed on each subscriber? Or is MSSQL a bit more intelligent than that?
2201
I want a to be rounded to 13.95.  &gt;&gt;&gt; a 13.949999999999999 &gt;&gt;&gt; round(a, 2) 13.949999999999999   The  function does not work the way I expected.
58926
in -> inner  out -> outer / (outter?)  What is the history or set of rules behind why 'inner' doubles the 'n' but 'outer' doesn't double the 't'?
30163
What is the difference between this:  void MyMethod(IMyInterface value) {     //... }   and this:  void MyMethod&lt;T&gt;(T value) where T : IMyInterface {     //... }
80556
What's going on?! Subtraction works fine until I get to 0.1 - 0.1. I'm in visual c# 2008 using the nonoba.com API.  Console.WriteLine("hit! " + Users[targetNum].character.health + " : " + player.character.profile.attackPower);  Users[targetNum].character.health -= player.character.profile.attackPower;  Console.WriteLine("health! " + Users[targetNum].character.health);   output:  hit! 0.1 : 0.1 health! 1.490116E-08   Thanks all - I might use the decimal type, as I'm normally adding/subtracting nice "round" numbers. For now I'll just go with:  if (Users[targetNum].character.health &lt;= 0.00001)   By the way I knew this wasn't really going to be a "bug" in c# - I thought it would either by a bug in my code or some lack of understanding, which it was.  Having read all the recommended reading, I'm going to conclude that my folly was due to normally using the ActionScript Number type, which maybe has a decimal rather than binary floating point - anyway, it would never give this output.
7653
public class doublePrecision {     public static void main(String[] args) {          double total = 0;         total += 5.6;         total += 5.8;         System.out.println(total);     } }   The above code prints:  11.399999999999   How would I get this to just print (or be able to use it as) 11.4?