HyukjinKwon commented on PR #59408:
URL: https://github.com/apache/spark/pull/59408#issuecomment-6179952461

   Thanks for testing it. I reproduced the 12345.1f case: the float stores 
12345.099609375, so a Float.toString-based floor(x, 1) returns 12345.1, and 
because Spark compares a decimal with a float by promoting both to Double, 
floor(x, 1) <= x is false. The same happens for a common value: floor(0.9f, 1) 
would return 0.9 while the float is 0.8999999761581421. Widening avoids this 
because the Double's canonical representation round-trips to the same Double 
the comparison uses, and it matches CAST(float AS DECIMAL) and round/bround. So 
I'd drop the Float.toString suggestion and keep widening in this PR, with the 
Float changes documented as they are now. Narrowing to Double would leave Float 
on the old fixed-scale cast, which also breaks the direction at boundaries 
(floor(nextDown(0.1f), 1) returned 0.1). I also see that the comparison and 
near-limit tests are now in the current head.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"conversation:6178418352","thread_id":"conversation:6178418352","verdict_sha256":"934509613198f15a2b8e0781079ad6e3054d256ee005973e9b0a990a0a1ef7cb"}
 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to