When I start messing about with a new language I have a few corner cases I try out just to see what answers I expect. For Squeak this has been OK except for cos. The two numbers I check are totally away from those I routinely use but are stress tests. (10**22) sin. -0.8522008497671888 "which is correct" (10**22) cos. -0.8522008497671888 "gives the same as sin which is suspicious" (2**120) sin. 0.377820109360752 "Also correct" (2**120) cos. 0.377820109360752 "Also the same as the sin case. I expect -0.9258790228548379"
On 2024-04-30 10:45, dgray@iesl.forth.gr wrote:
When I start messing about with a new language I have a few corner cases I try out just to see what answers I expect. For Squeak this has been OK except for cos. The two numbers I check are totally away from those I routinely use but are stress tests. (10**22) sin. -0.8522008497671888 "which is correct" (10**22) cos. -0.8522008497671888 "gives the same as sin which is suspicious" (2**120) sin. 0.377820109360752 "Also correct" (2**120) cos. 0.377820109360752 "Also the same as the sin case. I expect -0.9258790228548379" _______________________________________________ Beginners mailing list -- beginners@lists.squeakfoundation.org To unsubscribe send an email to beginners-leave@lists.squeakfoundation.org
Hello and welcome to Squeak! Thank you very much for reporting this, and congratulations on a very nice bug catch.
I think that you have identified an issue related to floating point data conversions. I am copying the main squeak-dev list on this, where I anticipate some lively follow up discussion.
For follow up on squeak-dev: The cosine logic for a large integer involves first converting the integer to a Float, then sending Float>>cos, which answers (self + Halfpi) sin. If the receiver is a very large floating point value, then self + Halfpi is the same as self, and we effectively calculate sin where cos was expected. At least I think that's what's happening, I'm sure someone will correct me quickly if I have it wrong :-)
Dave
On 2024-04-30 17:23, lewis@mail.msen.com wrote:
On 2024-04-30 10:45, dgray@iesl.forth.gr wrote:
When I start messing about with a new language I have a few corner cases I try out just to see what answers I expect. For Squeak this has been OK except for cos. The two numbers I check are totally away from those I routinely use but are stress tests. (10**22) sin. -0.8522008497671888 "which is correct" (10**22) cos. -0.8522008497671888 "gives the same as sin which is suspicious" (2**120) sin. 0.377820109360752 "Also correct" (2**120) cos. 0.377820109360752 "Also the same as the sin case. I expect -0.9258790228548379" _______________________________________________ Beginners mailing list -- beginners@lists.squeakfoundation.org To unsubscribe send an email to beginners-leave@lists.squeakfoundation.org
Hello and welcome to Squeak! Thank you very much for reporting this, and congratulations on a very nice bug catch.
I think that you have identified an issue related to floating point data conversions. I am copying the main squeak-dev list on this, where I anticipate some lively follow up discussion.
For follow up on squeak-dev: The cosine logic for a large integer involves first converting the integer to a Float, then sending Float>>cos, which answers (self + Halfpi) sin. If the receiver is a very large floating point value, then self + Halfpi is the same as self, and we effectively calculate sin where cos was expected. At least I think that's what's happening, I'm sure someone will correct me quickly if I have it wrong :-)
Dave
I just want to mention that follow up discussion on this topic is taking place on the the main squeak-dev list:
https://lists.squeakfoundation.org/archives/list/squeak-dev@lists.squeakfoun...
Dave
beginners@lists.squeakfoundation.org