develooper Front page | perl.perl5.porters | Postings from March 2008

RE: left_shift problem

Thread Previous | Thread Next
From:
Jan Dubois
Date:
March 23, 2008 16:34
Subject:
RE: left_shift problem
Message ID:
0eaf01c88d3e$5bc030f0$134092d0$@com
On Sun, 23 Mar 2008, Reini Urban wrote:
> 
> Im writing the perloptreeguts document at
> http://www.perlfoundation.org/perl5/index.cgi?optree_guts
> I got stuck at the first simple, and most innocent looking op I tried to
> use as an example.

[...]
 
> What makes we wonder is why the IV/UV discrimination is stored in the op
> (PL_op->op_private & HINT_INTEGER), and not taken from the type of the
> 1st arg at TOPi - 1st pop, 2nd arg -, which is here also used as return
> value.

Note that HINT_INTEGER doesn't say anything about the types of the operands;
it tells you that the "use integer" pragma was in effect when the code was
compiled, and that the op needs to implement the semantics prescribed by
this pragma:

| Note that this only affects how most of the arithmetic and relational
| B<operators> handle their operands and results, and B<not> how all
| numbers everywhere are treated. Specifically, C<use integer;> has the
| effect that before computing the results of the arithmetic operators
| (+, -, *, /, %, +=, -=, *=, /=, %=, and unary minus), the comparison
| operators (<, <=, >, >=, ==, !=, <=>), and the bitwise operators (|,
| &, ^, <<, >>, |=, &=, ^=, <<=, >>=), the operands have their
| fractional portions truncated (or floored), and the result will have
| its fractional portion truncated as well. In addition, the range of
| operands and results is restricted to that of familiar two's
| complement integers, i.e., -(2**31) .. (2**31-1) on 32-bit
| architectures, and -(2**63) .. (2**63-1) on 64-bit architectures.

Cheers,
-Jan 



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About