I have a number like 6511 and I want to round it up to 7000. How do
I tell the computer to round the numbers to the thousands place. I
know how to round decimals but not whole numbers. Thanks for you
Those are the correct results for rounding those numbers. Consider if you were using decimal numbers instead and rounding to the nearest whole number.
The easiest way to round is to add half the value you are rounding to, then truncate. If you are rounding (money) to the nearest cent then add half a cent and truncate. If you want to round to the nearest 1000 then add 500 and truncate.
I prefer not to use Math.Round because of one peculiarity.
Math.Round(1.5) = 2.0
Math.Round(2.5) = 2.0
I believe that a rounding function should behave the same whether or not the integer part is even or odd. I was always taught that x.5 always rounds up to the next integer value.
Tangent: I also have a beef with the Random class. Random.Next(minvalue,maxvalue) according to the documentation at msdn.microsoft.com, returns "A 32-bit signed integer greater than or equal to minValue and less than maxValue". Sorry, but "maxvalue" by definition means "the maximum value you want returned". Microsoft should fix this or change the parameter name to maxvalueminusone. You can't just go redefining words as it suits you like Alice's caterpillar.
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...