Sponsored Content
Full Discussion: help with data type sizes
Top Forums Programming help with data type sizes Post 302488049 by DGPickett on Friday 14th of January 2011 05:19:46 PM
Old 01-14-2011
Well, the first makes arithmetic sense, and the second makes memory allocation sense. Whether int 4 are in the heap or the stack, they are packed tight and so are 4 apart. Automatic are in the stack, so each pulls the stack pointer down by 4, but static or global are in the heap, which moves up.

---------- Post updated at 05:19 PM ---------- Previous update was at 05:14 PM ----------

Quote:
Originally Posted by Corona688
It's giving the offset in integer-sizes, I suppose. If you want it to just be integers for easy arithmetic, cast pointers into unsigned long before doing arithmetic.
I am not sure that is portable for all CPUs!

I think there is a printf option for printing pointers that is portable.
 

10 More Discussions You Might Find Interesting

1. Programming

FILE data type

Hi all, Can anyone tell me a little about the datatype FILE, which represents stream. What does its structure look like, and in which header file is it defined and so on... Ex : FILE *fp ; fp = fopen("filename", "w") ; (6 Replies)
Discussion started by: milhan
6 Replies

2. Programming

time_t data type-- what does start +1 mean?

Hi, I am trying to understand an very old C program. .... time_t start, end; ptr = localtime(&start); ... fprintf(out, "%-35s 01 %5s %2s %10d 1 5 /tty/M%d/%02d %24s", buffer3, job, ver, start, mach_num,atoi(buffer), asctime(ptr)); fprintf(out, "%-35s 03 %5s %2s %10d 1 5... (9 Replies)
Discussion started by: whatisthis
9 Replies

3. Programming

data type limitation

I am writing some code to do analysis on the file system (HP-UX 11.11). I am using stat(..) to get file information. My problem is that the file-size may exceed the data types defined in 'sys/stat.h' & 'sys/types.h' respectively. Thus file-sizes in the Giga-byte range are not read correctly.... (2 Replies)
Discussion started by: ALTRUNVRSOFLN
2 Replies

4. AIX

Value too large to be stored in data type???

Hello, I get this message : "Value too large to be stored in data type" when I try to open a 3Gb file. Can someone helps me to resolve the problem. Thank you very much (5 Replies)
Discussion started by: limame
5 Replies

5. UNIX for Dummies Questions & Answers

Directorie listing in Human form for data sizes

I have seen it done at my job before, there is a command that will make a notepad and show the directorie path, subfolders, and size of the subfolders? But i dont want it to go lower than 2 levels for example: folder_01 10 GB subfolder_02 10 GB subfolder_03 10 GB... (4 Replies)
Discussion started by: JUSSAN007
4 Replies

6. Shell Programming and Scripting

Perl data type checking

I am using perl 5.8.0. I need to check some values to see it they are floats. Our system does not have Data::Types so I can't use is_float. Is there something else that I can use? The only thing in Data is Dump.pm. I am not allowed to download anything to our system so I have to use what I have.... (3 Replies)
Discussion started by: ajgwin
3 Replies

7. UNIX for Advanced & Expert Users

Memory allocation for float data type

Dear All, How internally memory allocated when we declare the float data type. how many bytes allocated for decimal and how many bytes for fraction. kindly help me in this regards. (2 Replies)
Discussion started by: rajamohan
2 Replies

8. Shell Programming and Scripting

Can I split a 10GB file into 1 GB sizes using my repeating data pattern

I'm not a unix guy so excuses my ignorance... I'm the database ETL guy. I'm trying to be proactive and devise a plan B for a ETL process where I expect a file 10X larger than what I process daily for a recast job. The ETL may handle it but I just don't know. This file may need to be split... (3 Replies)
Discussion started by: john091
3 Replies

9. Web Development

Data type to use for prices with commas

Hi everybody, I`m very new with PHP and Databases and I having the follow issue with prices data.. The original information is in CSV files. The prices have formatted with commas and dots as follow: 12,300.99 -->(thousands separated by commas) 3,500.25 -->(thousands separated... (10 Replies)
Discussion started by: cgkmal
10 Replies

10. Programming

Incompatible data type fpos_t in C

This is from a program I wrote over in 1998 that I am trying to compile on a linux machine: void write_line (FILE *fp, int rec_no, line_rec *arec) { fpos_t woffset; woffset = (rec_no - 1) * sizeof(line_rec); fsetpos(fp,&woffset); fwrite(arec,sizeof(line_rec),1,fp); }On the line... (2 Replies)
Discussion started by: wbport
2 Replies
XS::APItest::KeywordRPN(3pm)				 Perl Programmers Reference Guide			      XS::APItest::KeywordRPN(3pm)

NAME
XS::APItest::KeywordRPN - write arithmetic expressions in RPN SYNOPSIS
use XS::APItest::KeywordRPN qw(rpn calcrpn); $triangle = rpn($n $n 1 + * 2 /); calcrpn $triangle { $n $n 1 + * 2 / } DESCRIPTION
This module supplies plugged-in keywords, using the new mechanism in Perl 5.11.2, that allow arithmetic to be expressed in reverse Polish notation, in an otherwise Perl program. This module has serious limitations and is not intended for real use: its purpose is only to test the keyword plugin mechanism. For that purpose it is part of the Perl core source distribution, and is not meant to be installed. RPN expression syntax Tokens of an RPN expression may be separated by whitespace, but such separation is usually not required. It is required only where unseparated tokens would look like a longer token. For example, "12 34 +" can be written as "12 34+", but not as "1234 +". An RPN expression may be any of: 1234 A sequence of digits is an unsigned decimal literal number. $foo An alphanumeric name preceded by dollar sign refers to a Perl scalar variable. Only variables declared with "my" or "state" are supported. If the variable's value is not a native integer, it will be converted to an integer, by Perl's usual mechanisms, at the time it is evaluated. A B "+" Sum of A and B. A B "-" Difference of A and B, the result of subtracting B from A. A B "*" Product of A and B. A B "/" Quotient when A is divided by B, rounded towards zero. Division by zero generates an exception. A B "%" Remainder when A is divided by B with the quotient rounded towards zero. Division by zero generates an exception. Because the arithmetic operators all have fixed arity and are postfixed, there is no need for operator precedence, nor for a grouping operator to override precedence. This is half of the point of RPN. An RPN expression can also be interpreted in another way, as a sequence of operations on a stack, one operation per token. A literal or variable token pushes a value onto the stack. A binary operator pulls two items off the stack, performs a calculation with them, and pushes the result back onto the stack. The stack starts out empty, and at the end of the expression there must be exactly one value left on the stack. OPERATORS
These are the operators being added to the Perl language. rpn(EXPRESSION) This construct is a Perl expression. EXPRESSION must be an RPN arithmetic expression, as described above. The RPN expression is evaluated, and its value is returned as the value of the Perl expression. calcrpn VARIABLE { EXPRESSION } This construct is a complete Perl statement. (No semicolon should follow the closing brace.) VARIABLE must be a Perl scalar "my" variable, and EXPRESSION must be an RPN arithmetic expression as described above. The RPN expression is evaluated, and its value is assigned to the variable. BUGS
This module only performs arithmetic on native integers, and only a small subset of the arithmetic operations that Perl offers. This is due to it being intended only for demonstration and test purposes. The RPN parser is liable to leak memory when a parse error occurs. It doesn't leak on success, however. SEE ALSO
Devel::Declare, "PL_keyword_plugin" in perlapi AUTHOR
Andrew Main (Zefram) <zefram@fysh.org> COPYRIGHT
Copyright (C) 2009 Andrew Main (Zefram) <zefram@fysh.org> LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.5 2012-11-03 XS::APItest::KeywordRPN(3pm)
All times are GMT -4. The time now is 09:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy