/usr/share/calc/help/sizeof is in apcalc-common 2.12.4.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | NAME
sizeof - number of bytes required for value
SYNOPSIS
sizeof(x)
TYPES
x any
return integer
DESCRIPTION
This is analogous to the C operator sizeof for the value only.
It attempts to assess the number of bytes in memory used to store
a value and all of its components. Unlike memsize(x), this
builtin does not include the size of the overhead.
Unlike size(x), this builtin incldues the trailing \0 byte on the
end of strings.
For numeric values, sizeof(x) ignores the demoninator if 'x' is
an integer. For complex values, sizeof(x) ignores the imaginary
part if 'x' is real. Because the 0, 1 and -1 numeric values are
shared static values, sizeof(x) reports such values as having
0 bytes of storage.
The number returned by sizeof(x) may be less than the actual number
used because, for example, more memory may have been allocated for
a string than is used: only the characters up to and including the
first '\0' are counted in calculating the contribution of the
string to sizeof(x).
The number returned by sizeof(x) may be greater (and indeed
substantially greater) than the number of bytes actually used.
For example, after:
a = sqrt(2);
mat A[3] = {a, a, a};
the numerical information for a, A[0], A[1], A[2] are stored in the
same memory, so the memory used for A is the same as if
its 3 elements were null values. The value returned by
sizeof(A) is calculated as A were defined by:
mat A[3] = {sqrt(2), sqrt(2), sqrt(2)}.
Similar sharing of memory occurs with literal strings.
For associative arrays, only the value part of the name/value pair
is counted.
The minimum value for sizeof(x) occurs for the null and error values.
EXAMPLES
The results for examples like these will depend to some extent on
the system being used. The following were for an SGI R4k machine
in 32-bit mode:
; print sizeof(null()), sizeof(0), sizeof(3), sizeof(2^32 - 1), sizeof(2^32)
8 68 68 68 72
; x = sqrt(2, 1e-100); print sizeof(x), sizeof(num(x)), sizeof(den(x))
148 108 108
; print sizeof(list()), sizeof(list(1)), sizeof(list(1,2))
28 104 180
; print sizeof(list()),sizeof(list(1)),sizeof(list(1,2)),sizeof(list(1,2,3))
28 104 180 256
; mat A[] = {1}; mat B[] = {1,2}; mat C[] = {1,2,3}; mat D[100,100];
; print sizeof(A), sizeof(B), sizeof(C), sizeof(D)
124 192 260 680056
; obj point {x,y,z}
; obj point P = {1,2,3}; print sizeof(P)
274
LIMITS
It is assumed sizeof(x) will fit into a system long integer.
LINK LIBRARY
none
SEE ALSO
size, fsize, strlen, digits
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: sizeof,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sizeof,v $
##
## Under source code control: 1996/05/24 02:04:04
## File existed as early as: 1996
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|