Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Integer types, and integer overflows, in C

C offers you the ability to define a whole variety of integer types:
  short int my_number;
  int my_number;
  long int my_number;

typically occupying 16, 32 and 64 bits of memory (but that is NOT a standard, and you may find different on some systems). And the amount of memory that's declared controls the minimum and maximum numbers that can be held. C, as a language which assumes the programmer knows what (s)he is doing, will not check for overflow for you, and will give results which are plain wrong arithmetically if you exceed the limits.

There's an example [here] from yesterday's C course, where I attempted to fill an array with an exponentially growing series of numbers, and ended up bursting even the capability of a long int. You'll note that (on my machine, in this case), I ended up getting zeros back rather than the largest number the machine can handle - a dramatic failure of my code.

There's a header file - limit.h - which #defines a whole load of constants such as INT_MAX to help you program to check for limits. There's an example of it in use [here] in a training example from our C Programming course.

(written 2012-01-25, updated 2012-01-28)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C201 - C and C based languages - C Language Fundamentals
  [888] Turning C from source to a running program - (2006-10-06)
  [1671] Compiling C programs with gcc - an overview - (2008-06-10)
  [2005] Variables and pointers and references - C and C++ - (2009-01-23)
  [2576] What does const mean? C and C++ - (2010-01-15)
  [2842] Staring a C course with Hello World - why? - (2010-06-30)
  [3120] Learning to write good programs in C and C++ - separating out repeated code - (2011-01-04)
  [3234] Your program - you just provide the filling in the sandwich - (2011-04-08)
  [3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
  [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
  [4324] Learning to program - variables and constants - (2014-11-22)
  [4555] Preprocessor directives in C and C++ - what they mean - (2015-10-27)
  [4566] C - why is slow to write and debug) but fast to run? - (2015-11-01)


Back to
Defining, declaring and initialising variables in C
Previous and next
or
Horse's mouth home
Forward to
Are we one man, one vote? No, and we never have been.
Some other Articles
Looking up
Back to Uni
Chars, char arrays and strings in C. Some early cautions and pitfalls.
Are we one man, one vote? No, and we never have been.
Integer types, and integer overflows, in C
Defining, declaring and initialising variables in C
Promoting a single one of your domains on the search engines
Learning about how to help people learning - and retaining
C++ Courses - do I get official certification at the end of my Well House course?
Emergency First Aid Provision at Well House Manor - part of the service
4759 posts, page by page
Link to page ... 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 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3591_Int ... -in-C.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb