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 for all FloatingPoint types is broken #10032

Closed
rickhg12hs opened this issue Feb 2, 2015 · 2 comments
Closed

round for all FloatingPoint types is broken #10032

rickhg12hs opened this issue Feb 2, 2015 · 2 comments

Comments

@rickhg12hs
Copy link
Contributor

julia> versioninfo()                                                                                                                                         
Julia Version 0.4.0-dev+3073
Commit 2f97c78* (2015-02-02 22:28 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: AMD Opteron 63xx class CPU
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Piledriver)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

julia> [(n, round(n)) for n::float_type = 0.5:1.0:10.5, float_type = subtypes(FloatingPoint)]                                                                
11x4 Array{(Any,Any),2}:
 (5e-01 with 256 bits of precision,0e+00 with 256 bits of precision)     (float16(0.5),float16(0.0))    (0.5f0,0.0f0)    (0.5,0.0)  
 (1.5e+00 with 256 bits of precision,2e+00 with 256 bits of precision)   (float16(1.5),float16(2.0))    (1.5f0,2.0f0)    (1.5,2.0)  
 (2.5e+00 with 256 bits of precision,2e+00 with 256 bits of precision)   (float16(2.5),float16(2.0))    (2.5f0,2.0f0)    (2.5,2.0)  
 (3.5e+00 with 256 bits of precision,4e+00 with 256 bits of precision)   (float16(3.5),float16(4.0))    (3.5f0,4.0f0)    (3.5,4.0)  
 (4.5e+00 with 256 bits of precision,4e+00 with 256 bits of precision)   (float16(4.5),float16(4.0))    (4.5f0,4.0f0)    (4.5,4.0)  
 (5.5e+00 with 256 bits of precision,6e+00 with 256 bits of precision)   (float16(5.5),float16(6.0))    (5.5f0,6.0f0)    (5.5,6.0)  
 (6.5e+00 with 256 bits of precision,6e+00 with 256 bits of precision)   (float16(6.5),float16(6.0))    (6.5f0,6.0f0)    (6.5,6.0)  
 (7.5e+00 with 256 bits of precision,8e+00 with 256 bits of precision)   (float16(7.5),float16(8.0))    (7.5f0,8.0f0)    (7.5,8.0)  
 (8.5e+00 with 256 bits of precision,8e+00 with 256 bits of precision)   (float16(8.5),float16(8.0))    (8.5f0,8.0f0)    (8.5,8.0)  
 (9.5e+00 with 256 bits of precision,1e+01 with 256 bits of precision)   (float16(9.5),float16(10.0))   (9.5f0,10.0f0)   (9.5,10.0) 
 (1.05e+01 with 256 bits of precision,1e+01 with 256 bits of precision)  (float16(10.5),float16(10.0))  (10.5f0,10.0f0)  (10.5,10.0)

julia>
@jiahao
Copy link
Member

jiahao commented Feb 2, 2015

This is correct. The default rounding mode changed in 0.4 (see #8750, #9344):

By default ("RoundNearest"), this will round to the nearest integer, with ties (fractional values of 0.5) being rounded to the even integer.

@rickhg12hs
Copy link
Contributor Author

Wow, I'll have to re-calibrate my understanding (and use) of rounding.

@jiahao : Thanks for the references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants