• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

An error in the Trunc function

Hi ,

There is no error ; this is the pitfall of using TRUNC.

TRUNC truncates any decimal portion of a number ; what you have as a result of the formula H6 * 24 is the number 3.99999999994179

Truncating this results in 3.

Never use TRUNC when you can easily use ROUND or any of its variants.

If at all you wish to truncate , then use it as follows :

=TRUNC(H6 * 24 + 0.1)

will result in a higher number as long as the decimal portion is between 0.9 and 0.999999 , and will result in a lower number in all other cases.

By replacing the 0.1 constant with any other constant , say 0.4 , you can decide that all numbers where the decimal portion is between 0.6 and 0.999999 will result in the higher number being output ; for all other decimal portions , the lower number will be output.

Narayan
 
Back
Top