We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
but the question is saying nearest integer not lower integer and ur comment is rounding it to lower integer not nearest
suppose avg is 243.9 and according to u it becomes 243.9-0.5=243.4 and then rounding it gives the upper integer always which is floor value /////though it should five 244 as answer for nearest integer.
Use FLOOR(), if you want to round your decimal to the lower integer. Examples:
FLOOR(1.9) => 1
FLOOR(1.1) => 1
Use ROUND(), if you want to round your decimal to the nearest integer. Examples:
ROUND(1.9) => 2
ROUND(1.1) => 1
Use CEIL(), if you want to round your decimal to the upper integer. Examples:
CEIL(1.9) => 2
CEIL(1.1) => 2
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Average Population of Each Continent
You are viewing a single comment's thread. Return to all comments →
but the question is saying nearest integer not lower integer and ur comment is rounding it to lower integer not nearest suppose avg is 243.9 and according to u it becomes 243.9-0.5=243.4 and then rounding it gives the upper integer always which is floor value /////though it should five 244 as answer for nearest integer.
Use FLOOR(), if you want to round your decimal to the lower integer. Examples:
FLOOR(1.9) => 1 FLOOR(1.1) => 1 Use ROUND(), if you want to round your decimal to the nearest integer. Examples:
ROUND(1.9) => 2 ROUND(1.1) => 1 Use CEIL(), if you want to round your decimal to the upper integer. Examples:
CEIL(1.9) => 2 CEIL(1.1) => 2