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.
you are missing a " ; " after read X ... also, bc truncates in a strange way and the challenge author, in spite of writing (now) "...rounded up ...", expects a value rounded in another strange way. (Seems there are solutions using printf, but for doing it within bc only I had to use "... if ( x < 0 ) { x = x - 0.0004999;} else { x = x + 0.0004999; } ..." which looks highly nonstandard to me. (For normal mathematicians, round(x) := floor(x+0.5), so round(1.5) = 2 and round(-1.5) = -1. This is not the convention used here...)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Arithmetic Operations
You are viewing a single comment's thread. Return to all comments →
you are missing a " ; " after read X ... also,
bc
truncates in a strange way and the challenge author, in spite of writing (now) "...rounded up ...", expects a value rounded in another strange way. (Seems there are solutions using printf, but for doing it within bc only I had to use "... if ( x < 0 ) { x = x - 0.0004999;} else { x = x + 0.0004999; } ..." which looks highly nonstandard to me. (For normal mathematicians, round(x) := floor(x+0.5), so round(1.5) = 2 and round(-1.5) = -1. This is not the convention used here...)