Ticket #1168 (new bug)

Opened 12 years ago

Last modified 12 years ago

PMC to Float conversion not working as documented

Reported by: jkeenan Owned by:
Priority: normal Milestone:
Component: core Version: 1.7.0
Severity: medium Keywords:
Cc: jonathan dukeleto NotFound Language:
Patch status: Platform:


Here are lines 1101-1104 of docs/book/pir/ch04_variables.pod:

  $P1 = box "5 birds"
  $S1 = $P1           # the string "5 birds"
  $I1 = $P1           # the integer 5
  $N1 = $P1           # the number 5.0

On the basis of the comments, if I were to say each of the 4 variables receiving assignment, I would expect the output to be:

5 birds
5 birds

This is not the case.

[study] 511 $ cat 5birds.pir 
.sub main :main
    $P1 = box "5 birds"
    $S1 = $P1
    $I1 = $P1
    $N1 = $P1
    say $P1
    say $S1
    say $I1
    say $N1
[study] 512 $ ./parrot 5birds.pir 
5 birds
5 birds

Is this merely a documentation error? Or is it something more serious?

Thank you very much.

kid51 (working his way thru the PIR book)

Change History

Changed 12 years ago by dukeleto

I would prefer that unboxing a string that is not a valid number turn into a NaN in a numeric register and MAX_INT or 0 on an integer register. I think it should be MAX_INT, if we care about ieee754-2008, but I have to verify that. Also, is it documented or tested anywhere that this should print "5" instead of "5.0" ?

parrot_shell 5> $P1 = box "5"
$N1 = $P1
say $N1
Time: 0.0160158 wallclock secs 
Note: See TracTickets for help on using tickets.