Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

round the float value before we cast to Int #558

Merged
merged 1 commit into from
Nov 26, 2015

Commits on Nov 19, 2015

  1. round the float value before we cast to Int

    Old code will cause the visible index incorrect, smaller by 1.
    
    Int() simply cuts the fractional part, which usually isn't the desired behaviour ;) Int(round(f)) does the job
    
    I met this when that the last label should be year 2015, but it actually shows 2014. It turned out that pt.x is 3.9999999999999987, and Int(pt.x) is 3
    
    More information about the casting can be found here:http://stackoverflow.com/questions/24029917/convert-float-to-int-in-swift
    liuxuan30 committed Nov 19, 2015
    Configuration menu
    Copy the full SHA
    862de89 View commit details
    Browse the repository at this point in the history