[prev in list] [next in list] [prev in thread] [next in thread]
List: squeak-beginners
Subject: [Newbies] Re: Trigonometric function error
From: lewis () mail ! msen ! com
Date: 2024-04-30 21:23:26
Message-ID: c27fcd40a2c4db4cf4061115fb362a94 () mail ! msen ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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
[Attachment #5 (unknown)]
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" \
/></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'> <div \
id="signature"></div> <p id="reply-intro">On 2024-04-30 10:45, dgray@iesl.forth.gr \
wrote:</p> <blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px \
solid; margin: 0"> <div class="pre" style="margin: 0; padding: 0; font-family: \
monospace">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.<br />For Squeak this has been OK except \
for cos.<br />The two numbers I check are totally away from those I routinely use but \
are stress tests.<br />(10**22) sin. -0.8522008497671888 "which is correct"<br \
/>(10**22) cos. -0.8522008497671888 "gives the same as sin which is suspicious"<br \
/>(2**120) sin. 0.377820109360752 "Also correct"<br />(2**120) cos. \
0.377820109360752 "Also the same as the sin case. I expect -0.9258790228548379"<br \
/>_______________________________________________<br />Beginners mailing list -- <a \
href="mailto:beginners@lists.squeakfoundation.org">beginners@lists.squeakfoundation.org</a><br \
/>To unsubscribe send an email to <a \
href="mailto:beginners-leave@lists.squeakfoundation.org">beginners-leave@lists.squeakfoundation.org</a></div>
</blockquote>
<p><br /></p>
<p>Hello and welcome to Squeak! Thank you very much for reporting this, and \
congratulations on a very nice bug catch.</p> <p>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.</p> <p>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 \
:-)</p> <p>Dave</p>
<p><br /></p>
<p><br /></p>
<p><br /></p>
</body></html>
_______________________________________________
Beginners mailing list -- beginners@lists.squeakfoundation.org
To unsubscribe send an email to beginners-leave@lists.squeakfoundation.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic