Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #31980] Examples

1 view
Skip to first unread message

James Ghofulpo

unread,
Oct 14, 2004, 9:53:11 AM10/14/04
to bugs-bi...@rt.perl.org
# New Ticket Created by "Ghofulpo, James \(GE Transportation\)"
# Please include the string: [perl #31980]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=31980 >


Is it the intended operation of the 'factorial' program on the Parrot examples page to truncate the results? Looks like a bug to me...

James Ghofulpo
General Electric Transportation Systems
2901 East Lake Road 63-2E, Erie, PA 16531
Tel: +1-814-875-5747 Fax: +1-201-477-6930

NOTICE: The information contained in this email and any document attached hereto is intended only for the named recipient(s). It is the property of the General Electric Company and shall not be used, disclosed or reproduced without the express written consent of the General Electric Company. If you are not the intended recipient (or the employee or agent responsible for delivering this message in confidence to the intended recipient(s)), you are hereby notified that you have received this transmittal in error, and any review, dissemination, distribution or copying of this transmittal or its attachments is strictly prohibited. If you have received this transmittal and/or attachments in error, please notify me immediately by reply email or telephone 814-875-5747 and immediately delete this message and all its attachments. Thank you.

Bernhard Schmalhofer via RT

unread,
Sep 8, 2005, 4:43:35 PM9/8/05
to perl6-i...@perl.org
> [ja...@ghofulpo.com - Di 19. Okt 2004, 19:49:44]:

> Is it the intended operation of the 'factorial' program on the Parrot
> examples page to
> truncate the results? Looks like a bug to me...

I have checked the factorial example on
http://www.parrotcode.org/examples/pasm.html.

Starting with 13! incorrect results are indeed returned on my 32bit
Linux machine.
Should there a promotion to BigInt be taking place? on an overflow
indication?

--
/* Bernhard.S...@gmx.de */

Leopold Toetsch

unread,
Sep 9, 2005, 8:52:35 AM9/9/05
to parrotbug...@parrotcode.org, perl6-i...@perl.org

Most of the examples are really old and partially outdated. I think there
should be very few PASM examples, more complex examples should be in
PIR. Regarding the factorial: using .Integer PMCs would fix it.

leo

Will Coleda

unread,
Sep 9, 2005, 9:25:41 AM9/9/05
to l...@toetsch.at, parrotbug...@parrotcode.org, perl6-i...@perl.org
Switching to Integer doesn't help unless you have a bigint lib, at
least on my box:

The first 15 factorials are:
1
2
6
24
120
720
5040
40320
362880
3628800
39916800
479001600
no bigint lib loaded
current instr.: '(null)' pc 16 ((unknown file):-1)

To address the other point, I'll reorganize the examples in the next
few days to reduce the size of the PASM and split up the PIR into
multiple pages.

Joshua Hoblitt

unread,
Sep 11, 2005, 4:33:36 AM9/11/05
to Bernhard Schmalhofer via RT, perl6-i...@perl.org
On Thu, Sep 08, 2005 at 01:43:35PM -0700, Bernhard Schmalhofer via RT wrote:
> I have checked the factorial example on
> http://www.parrotcode.org/examples/pasm.html.
>
> Starting with 13! incorrect results are indeed returned on my 32bit
> Linux machine.

I'm not surprised, the values listed on that webpage for !13, !14 and
!15 are wrong.

According to my lisp interpreter the correct values (Google confirmed)
are:

13! = 6227020800
14! = 87178291200
15! = 1307674368000

In case someone should be really bored, here's a link to more then you
ever wanted to know about factorials:

http://mathworld.wolfram.com/Factorial.html

Cheers,

-J

--

Bernhard Schmalhofer

unread,
Sep 11, 2005, 7:06:57 AM9/11/05
to Joshua Hoblitt, perl6-i...@perl.org
Joshua Hoblitt schrieb:

>I'm not surprised, the values listed on that webpage for !13, !14 and
>!15 are wrong.
>
>According to my lisp interpreter the correct values (Google confirmed)
>are:
>
> 13! = 6227020800
> 14! = 87178291200
> 15! = 1307674368000
>
>

Well, the problem is that Parrot indeed returns the incorrect values
that are
mentioned in the webpage.

CU, Bernhard

Joshua Hoblitt

unread,
Sep 11, 2005, 8:29:44 AM9/11/05
to Bernhard Schmalhofer, perl6-i...@perl.org
On Sun, Sep 11, 2005 at 01:06:57PM +0200, Bernhard Schmalhofer wrote:
> Well, the problem is that Parrot indeed returns the incorrect values
> that are
> mentioned in the webpage.

I happen to get the correct answers out to 20! but only because I'm on
64bit hardware. The real issue is that the C standards specifies integer
overflow as undefined behavior. Supposedly, with the proper flags, you
can get gcc to give you a SIGFPE on signed overflow. AFAIK - there is
no portable way to trap the overflow. I think the best we can hope for
is automatic promotion of literals by the compiler/assembler.

-J

--

Joshua Hoblitt

unread,
Sep 11, 2005, 4:55:34 PM9/11/05
to Bernhard Schmalhofer, perl6-i...@perl.org
-J

--


On Sun, Sep 11, 2005 at 01:06:57PM +0200, Bernhard Schmalhofer wrote:

> Well, the problem is that Parrot indeed returns the incorrect values
> that are
> mentioned in the webpage.

I'd like to propose that we fix the n! values listed on the examples page,
change the code example to the snippet below, and add a warning about BigInt's
requiring that GMP is installed.

--
print "The first 30 factorials are:\n"
set I1, 0
set I2, 30
new P0, .BigInt
set P0, 1
REDO: inc I1
mul P0, P0, I1
print P0
print "\n"
lt I1, I2, REDO
DONE: end
--

Cheers,

-J

--

Bernhard Schmalhofer

unread,
Sep 12, 2005, 1:24:47 PM9/12/05
to Joshua Hoblitt, perl6-i...@perl.org
Joshua Hoblitt schrieb:

>I'd like to propose that we fix the n! values listed on the examples page,
>change the code example to the snippet below, and add a warning about BigInt's
>requiring that GMP is installed.
>
>

Hi,

I have added information on how to provide patches to
http://www.parrotcode.org
to docs/submissions.pod.

Basically you create patches against
https://*svn*.perl.org/perl.org/docs/live/*parrotcode*/
<http://www.google.com/url?sa=D&q=https://svn.perl.org/perl.org/docs/live/parrotcode/>
(guest/guest)
and send them to webmaster at perl.org.

CU, Bernhard

Joshua Hoblitt

unread,
Sep 12, 2005, 3:32:42 PM9/12/05
to Bernhard Schmalhofer, perl6-i...@perl.org, webm...@perl.org
On Mon, Sep 12, 2005 at 07:24:47PM +0200, Bernhard Schmalhofer wrote:
> I have added information on how to provide patches to
> http://www.parrotcode.org
> to docs/submissions.pod.
>
> Basically you create patches against
> https://*svn*.perl.org/perl.org/docs/live/*parrotcode*/
> <http://www.google.com/url?sa=D&q=https://svn.perl.org/perl.org/docs/live/parrotcode/>
> (guest/guest)
> and send them to webmaster at perl.org.

The guest account doesn't seem to be working from either subversion or my
web browser.

--
$ svn co --username guest --password guest https://svn.perl.org/perl.org/docs/live/parrotcode/
Authentication realm: <https://svn.perl.org:443> perl.org
Username: guest
Password for 'guest':
Authentication realm: <https://svn.perl.org:443> perl.org
Username: guest
Password for 'guest':
svn: PROPFIND request failed on '/perl.org/docs/live/parrotcode'
svn: PROPFIND of '/perl.org/docs/live/parrotcode': authorization failed (https://svn.perl.org)
--

Cheers,

-J

--

Joshua Hoblitt via RT

unread,
Feb 20, 2006, 5:44:14 PM2/20/06
to perl6-i...@perl.org
What happened to the factorial PASM example? It seems to have
disappeared and it hasn't re-appeared as a PIR example either.

-J

--

Leopold Toetsch

unread,
Feb 20, 2006, 7:03:59 PM2/20/06
to parrotbug...@parrotcode.org, Perl 6 Internals

On Feb 20, 2006, at 23:44, Joshua Hoblitt via RT wrote:

> What happened to the factorial PASM example? It seems to have
> disappeared and it hasn't re-appeared as a PIR example either.

It used bogus high numbers beyond int32 range and was just broken.
leo

Joshua Hoblitt

unread,
Feb 20, 2006, 7:24:07 PM2/20/06
to Leopold Toetsch, parrotbug...@parrotcode.org, Perl 6 Internals

Only because it was using integer registers. Limiting it to low
factorial values or using Integer pmcs would resolve the issue. I'm
going to add a PIR example using Integer pmcs unless there are any
objections.

-J

--

Allison Randal via RT

unread,
Jun 16, 2007, 8:28:35 PM6/16/07
to perl6-i...@perl.org

Did you add the examples? I'd like to close the ticket.

Allison

Stephen Weeks

unread,
Mar 16, 2008, 7:32:39 PM3/16/08
to Allison Randal via RT
Not long ago, Allison Randal via RT proclaimed...

The examples aren't on the website, but examples/pasm/fact.pasm is fixed
as of r26432.

0 new messages