Re: confusion about real vs not real zero
Sorawee Porncharoenwase <[email protected]> Fri, 19 Nov 2021 12:30:07 -0800
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <CADcuegsLHOrP9coJGwbd3Mqj4YKovzBvBoSdSk83xtVT5yb9Bg@mail.gmail.com> |
--000000000000be4d9905d12a240d Content-Type: text/plain; charset="UTF-8" Yeah, I was about to reply that I don't think there's a workaround, too. What is your goal, though? Do you intend to support complex numbers properly right now? In particular, that problematic code is random generation from contracts, which is rarely invoked anyway. Intuitively, there's no reason why the complex number feature is required to get the code running. So one potential solution is to not support complex numbers right now, and compile all complex number literals to a JS expression that throws an exception at runtime. On Fri, Nov 19, 2021 at 12:20 PM Sam Tobin-Hochstadt <[email protected]> wrote: > On Fri, Nov 19, 2021 at 3:13 PM Stephen Chang <[email protected]> > wrote: > > > > Lol I read that page and still didn't get it. > > > > Any opinion for a potential workaround? > > It depends what you mean by "workaround". The distinction between > exact and inexact numbers is pretty deeply built-in to how Racket > numbers work, so there's not going to be a simple workaround that > fixes this issue. > > For RacketScript I think the choices are (a) use floats for everything > and have semantics that diverge substantially from Racket or (b) have > a separate implementation of integers that's not JS numbers (maybe JS > bigints would work). > > Sam > > > > > On Fri, Nov 19, 2021 at 3:08 PM Sorawee Porncharoenwase > > <[email protected]> wrote: > > > > > > I had this exact same question when I looked at the RacketScript issue > lol. > > > > > > The answer is https://docs.racket-lang.org/reference/numbers.html: > > > > > > a complex number with an exact zero imaginary part is a real number. > > > > > > Since 0.0 is not exact, 0.0i is not a real number. > > > > > > On Fri, Nov 19, 2021 at 11:59 AM Stephen Chang <[email protected]> > wrote: > > >> > > >> In the following, why is the first considered a real number but the > > >> second considered not real > > >> > > >> > (real? 0.0+0i) > > >> #t > > >> > (real? 0.0+0.0i) > > >> #f > > >> > > >> -- > > >> You received this message because you are subscribed to the Google > Groups "Racket Users" group. > > >> To unsubscribe from this group and stop receiving emails from it, > send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] > > >> To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CAFfiA1%2BYygGrLH2rtwby8AWg7Edyvq-tzmANTNypq5Rqd-eXFw%40mail.gmail.com > . > > > > -- > > You received this message because you are subscribed to the Google > Groups "Racket Users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] > > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CAFfiA1%2B3yRzzh%3DKhcOddt0geMezNsxQGHqzwGTYbZjLekUQ8kQ%40mail.gmail.com > . > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CADcuegsLHOrP9coJGwbd3Mqj4YKovzBvBoSdSk83xtVT5yb9Bg%40mail.gmail.com. --000000000000be4d9905d12a240d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Yeah, I was about to reply that I don't think the= re's a workaround, too.</div><div><br></div><div>What is your goal, tho= ugh? Do you intend to support complex numbers properly right now? In partic= ular, that problematic code is random generation from contracts, which is r= arely invoked anyway. Intuitively, there's no reason why the complex nu= mber feature is required to get the code running.</div><div><br></div><div>= So one potential solution is to not support complex numbers right now, and= compile all complex number literals to a JS expression that throws an exce= ption at runtime.<br></div><div><br></div><div><br></div></div><br><div cla= ss=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Nov 19, 20= 21 at 12:20 PM Sam Tobin-Hochstadt <<a href=3D"mailto:[email protected]"= >[email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote= " style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);= padding-left:1ex">On Fri, Nov 19, 2021 at 3:13 PM Stephen Chang <<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>= > wrote:<br> ><br> > Lol I read that page and still didn't get it.<br> ><br> > Any opinion for a potential workaround?<br> <br> It depends what you mean by "workaround". The distinction between= <br> exact and inexact numbers is pretty deeply built-in to how Racket<br> numbers work, so there's not going to be a simple workaround that<br> fixes this issue.<br> <br> For RacketScript I think the choices are (a) use floats for everything<br> and have semantics that diverge substantially from Racket or (b) have<br> a separate implementation of integers that's not JS numbers (maybe JS<b= r> bigints would work).<br> <br> Sam<br> <br> ><br> > On Fri, Nov 19, 2021 at 3:08 PM Sorawee Porncharoenwase<br> > <<a href=3D"mailto:[email protected]" target=3D"_blank">soraw= [email protected]</a>> wrote:<br> > ><br> > > I had this exact same question when I looked at the RacketScript = issue lol.<br> > ><br> > > The answer is <a href=3D"https://docs.racket-lang.org/reference/n= umbers.html" rel=3D"noreferrer" target=3D"_blank">https://docs.racket-lang.= org/reference/numbers.html</a>:<br> > ><br> > > a complex number with an exact zero imaginary part is a real numb= er.<br> > ><br> > > Since 0.0 is not exact, 0.0i is not a real number.<br> > ><br> > > On Fri, Nov 19, 2021 at 11:59 AM Stephen Chang <<a href=3D"mai= lto:[email protected]" target=3D"_blank">[email protected]</a>> wr= ote:<br> > >><br> > >> In the following, why is the first considered a real number b= ut the<br> > >> second considered not real<br> > >><br> > >> > (real? 0.0+0i)<br> > >> #t<br> > >> > (real? 0.0+0.0i)<br> > >> #f<br> > >><br> > >> --<br> > >> You received this message because you are subscribed to the G= oogle Groups "Racket Users" group.<br> > >> To unsubscribe from this group and stop receiving emails from= it, send an email to <a href=3D"mailto:racket-users%2Bunsubscribe@googlegr= oups.com" target=3D"_blank">racket-users+unsubscribe-/[email protected]</a>.<= br> > >> To view this discussion on the web visit <a href=3D"https://g= roups.google.com/d/msgid/racket-users/CAFfiA1%2BYygGrLH2rtwby8AWg7Edyvq-tzm= ANTNypq5Rqd-eXFw%40mail.gmail.com" rel=3D"noreferrer" target=3D"_blank">htt= ps://groups.google.com/d/msgid/racket-users/CAFfiA1%2BYygGrLH2rtwby8AWg7Edy= vq-tzmANTNypq5Rqd-eXFw%40mail.gmail.com</a>.<br> ><br> > --<br> > You received this message because you are subscribed to the Google Gro= ups "Racket Users" group.<br> > To unsubscribe from this group and stop receiving emails from it, send= an email to <a href=3D"mailto:racket-users%2Bunsubscribe-/[email protected]"= target=3D"_blank">racket-users+unsubscribe-/[email protected]</a>.<br> > To view this discussion on the web visit <a href=3D"https://groups.goo= gle.com/d/msgid/racket-users/CAFfiA1%2B3yRzzh%3DKhcOddt0geMezNsxQGHqzwGTYbZ= jLekUQ8kQ%40mail.gmail.com" rel=3D"noreferrer" target=3D"_blank">https://gr= oups.google.com/d/msgid/racket-users/CAFfiA1%2B3yRzzh%3DKhcOddt0geMezNsxQGH= qzwGTYbZjLekUQ8kQ%40mail.gmail.com</a>.<br> </blockquote></div> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups &= quot;Racket Users" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:racket-users+unsubscribe-/[email protected]">racket= -users+unsubscribe-/[email protected]</a>.<br /> To view this discussion on the web visit <a href=3D"https://groups.google.c= om/d/msgid/racket-users/CADcuegsLHOrP9coJGwbd3Mqj4YKovzBvBoSdSk83xtVT5yb9Bg= %40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.go= ogle.com/d/msgid/racket-users/CADcuegsLHOrP9coJGwbd3Mqj4YKovzBvBoSdSk83xtVT= 5yb9Bg%40mail.gmail.com</a>.<br /> --000000000000be4d9905d12a240d--