* real numbers and integer-expt.
@ 2002-03-13 8:36 Rob Browning
2002-03-13 19:23 ` Marius Vollmer
0 siblings, 1 reply; 7+ messages in thread
From: Rob Browning @ 2002-03-13 8:36 UTC (permalink / raw)
integer-expt says:
SCM_DEFINE (scm_integer_expt, "integer-expt", 2, 0, 0,
(SCM n, SCM k),
"Return @var{n} raised to the non-negative integer exponent\n"
"@var{k}.\n"
"\n"
but in the code we check to see if k satisfies SCM_REALP and if it
does, we coerce it to an int and see if we get any lossage. If we
don't then we decide it's OK to use it. Is that what we want, or
should callers be required to use inexact->exact when appropriate?
Thanks
--
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C 64AE 78FE E5FE F0CB A0AD
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: real numbers and integer-expt.
2002-03-13 8:36 real numbers and integer-expt Rob Browning
@ 2002-03-13 19:23 ` Marius Vollmer
2002-03-13 21:23 ` Rob Browning
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Marius Vollmer @ 2002-03-13 19:23 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
> integer-expt says:
>
> SCM_DEFINE (scm_integer_expt, "integer-expt", 2, 0, 0,
> (SCM n, SCM k),
> "Return @var{n} raised to the non-negative integer exponent\n"
> "@var{k}.\n"
> "\n"
>
> but in the code we check to see if k satisfies SCM_REALP and if it
> does, we coerce it to an int and see if we get any lossage. If we
> don't then we decide it's OK to use it. Is that what we want,
Yes. Floats can be integers, too. However, there's a bug
nevertheless: floats can represent integers that don't fit into 32 bit
ints. Also, complex numbers can be ints as well. Also also, the
docstring talks about non-negative powers, but the code handles
negative ones as well.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: real numbers and integer-expt.
2002-03-13 19:23 ` Marius Vollmer
@ 2002-03-13 21:23 ` Rob Browning
2002-03-13 21:32 ` Rob Browning
2002-03-13 21:48 ` Rob Browning
2 siblings, 0 replies; 7+ messages in thread
From: Rob Browning @ 2002-03-13 21:23 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <mvo@zagadka.ping.de> writes:
> Yes. Floats can be integers, too. However, there's a bug
> nevertheless: floats can represent integers that don't fit into 32
> bit ints. Also, complex numbers can be ints as well. Also also,
> the docstring talks about non-negative powers, but the code handles
> negative ones as well.
OK, so I'll fix that. What would be the right way (c-side) to handle
a negative arg? i.e. what would be the right error func? (obviously
not WTA).
--
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C 64AE 78FE E5FE F0CB A0AD
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: real numbers and integer-expt.
2002-03-13 19:23 ` Marius Vollmer
2002-03-13 21:23 ` Rob Browning
@ 2002-03-13 21:32 ` Rob Browning
2002-03-13 21:48 ` Rob Browning
2 siblings, 0 replies; 7+ messages in thread
From: Rob Browning @ 2002-03-13 21:32 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <mvo@zagadka.ping.de> writes:
> Yes. Floats can be integers, too. However, there's a bug
> nevertheless: floats can represent integers that don't fit into 32 bit
> ints. Also, complex numbers can be ints as well.
OK, I brushed up on the r5rs bits -- so now I know what they mean here
exactly.
Thanks
--
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C 64AE 78FE E5FE F0CB A0AD
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: real numbers and integer-expt.
2002-03-13 19:23 ` Marius Vollmer
2002-03-13 21:23 ` Rob Browning
2002-03-13 21:32 ` Rob Browning
@ 2002-03-13 21:48 ` Rob Browning
2002-03-20 22:32 ` Marius Vollmer
2 siblings, 1 reply; 7+ messages in thread
From: Rob Browning @ 2002-03-13 21:48 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <mvo@zagadka.ping.de> writes:
> Yes. Floats can be integers, too. However, there's a bug
> nevertheless: floats can represent integers that don't fit into 32
> bit ints. Also, complex numbers can be ints as well.
OK, that's a bit confusing -- we have SCM_COMPLEXP which does *not*
mean the same thing as scm_complex_p -- the former checks to make sure
the object, tag-wise, is a complex smob, the latter checks to see if
the object actually contains a complex number, so we have
(complex? 3) -> #t
but
SCM_COMPLEX(SCM_MKINUM(3)) -> 0
--
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C 64AE 78FE E5FE F0CB A0AD
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: real numbers and integer-expt.
2002-03-13 21:48 ` Rob Browning
@ 2002-03-20 22:32 ` Marius Vollmer
2002-03-20 22:54 ` Rob Browning
0 siblings, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 2002-03-20 22:32 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
> Marius Vollmer <mvo@zagadka.ping.de> writes:
>
> > Yes. Floats can be integers, too. However, there's a bug
> > nevertheless: floats can represent integers that don't fit into 32
> > bit ints. Also, complex numbers can be ints as well.
>
> OK, that's a bit confusing -- we have SCM_COMPLEXP which does *not*
> mean the same thing as scm_complex_p -- the former checks to make sure
> the object, tag-wise, is a complex smob, the latter checks to see if
> the object actually contains a complex number, so we have
>
> (complex? 3) -> #t
>
> but
>
> SCM_COMPLEX(SCM_MKINUM(3)) -> 0
Yes, good point. I wasn't aware of that.
I guess we need to first answer what the purpose of 'integer-expt' is.
Given 'expt' is it useful to have 'integer-expt' as well? Is
integer-expt really only for exact numbers and not for integers? Is
it just a subset of 'expt' for use from C code?
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: real numbers and integer-expt.
2002-03-20 22:32 ` Marius Vollmer
@ 2002-03-20 22:54 ` Rob Browning
0 siblings, 0 replies; 7+ messages in thread
From: Rob Browning @ 2002-03-20 22:54 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <mvo@zagadka.ping.de> writes:
>> OK, that's a bit confusing -- we have SCM_COMPLEXP which does *not*
>> mean the same thing as scm_complex_p -- the former checks to make sure
>> the object, tag-wise, is a complex smob, the latter checks to see if
>> the object actually contains a complex number, so we have
>>
>> (complex? 3) -> #t
>>
>> but
>>
>> SCM_COMPLEX(SCM_MKINUM(3)) -> 0
>
> Yes, good point. I wasn't aware of that.
>
>
> I guess we need to first answer what the purpose of 'integer-expt' is.
> Given 'expt' is it useful to have 'integer-expt' as well? Is
> integer-expt really only for exact numbers and not for integers? Is
> it just a subset of 'expt' for use from C code?
All good questions. I get the impression that at least in part, it
was designed as a "helper" for use by other numbers.c functions.
--
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C 64AE 78FE E5FE F0CB A0AD
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-03-20 22:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-13 8:36 real numbers and integer-expt Rob Browning
2002-03-13 19:23 ` Marius Vollmer
2002-03-13 21:23 ` Rob Browning
2002-03-13 21:32 ` Rob Browning
2002-03-13 21:48 ` Rob Browning
2002-03-20 22:32 ` Marius Vollmer
2002-03-20 22:54 ` Rob Browning
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).