Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMC to Float conversion not working as documented #423

Open
jkeenan opened this issue Nov 1, 2009 · 1 comment
Open

PMC to Float conversion not working as documented #423

jkeenan opened this issue Nov 1, 2009 · 1 comment

Comments

@jkeenan
Copy link
Contributor

jkeenan commented Nov 1, 2009

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
5
5.0

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
.end
[study] 512 $ ./parrot 5birds.pir 
5 birds
5 birds
5
0

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

Thank you very much.

kid51 (working his way thru the PIR book)

Originally http://trac.parrot.org/parrot/ticket/1168

@leto
Copy link
Member

leto commented Nov 1, 2009

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
Output:
5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants