in reply to Number size equal to one byte

What do you mean by "size"? If you mean it in the way as in C, the answer is no. It takes quite some bytes just to represent anything in Perl.

Here's a schematic view of an integer in Perl:

      SvIV            xpviv 
    +--------+      +--------+
    | Any +--+----->| (PVX)  |
    +--------+      +--------+
    | RefCo  |      | (CUR)  |
    +--------+      +--------+
    | Fl  |T |      | (LEN)  |
    +--------+      +--------+
                    |  IVX   |
                    +--------+
All fields are 32 bits wide. Note that there are other ways integers can be stored in Perl, in might have been used as a float or a string; then the size will increase. But the minimum size is 28 bytes.

Abigail

Replies are listed 'Best First'.
Re: Re: Number size equal to one byte
by blogan (Monk) on Jul 05, 2002 at 14:39 UTC
    Could you elaborate on your design and explain what the acronym's mean? Thanks.
      Could you elaborate on your design and explain what the acronym's mean?
      Any:    A pointer to anything.
      Refco:  Reference counter.
      Fl:     Flags.
      T:      Type.
      PVX:    Pointer value (a pointer to a string).
      CUR:    Length of above string.    
      LEN:    Size of allocated area for string.
      IVX:    Integer value.
      
      For an SvIV, the PVX, CUR and LEN values are unused.

      For much more details, visit Gisles PerlGuts Illustrated.

      Abigail

Re: Re: Number size equal to one byte
by Anonymous Monk on Jul 06, 2002 at 03:10 UTC
    Er, actually, the minimum is 16 bytes. Not only are the PVX, CUR and LEN not used, they're not even allocated on any scalar that has never been used as a string. The allocator actually allocates a block of contiguous integers, and returns a fake Any pointer to where the PVX would be if there were one, so that the access code doesn't have to have a conditional offset. If you looked in the PVX, CUR and LEN of a bare integer, you'd actually find the integers of other previously constructed values.

    Larry