Problem with big numbers in C

why should a code like this should provide a so high result when I give it the number 4293974227 (or higher)

int main (int argc, char *argv[]) { unsigned long long int i; unsigned long long int z = atoi(argv[1]); unsigned long long int tmp1 = z; unsigned long long int *numbers = malloc (sizeof (unsigned long long int) * 1000); for (i=0; tmp1<=tmp1+1000; i++, tmp1++) { numbers[i] = tmp1; printf("\n%llu - %llu", numbers[i], tmp1); } }

Result should start with the provided number but starts like this:

18446744073708558547 - 18446744073708558547 18446744073708558548 - 18446744073708558548 18446744073708558549 - 18446744073708558549 18446744073708558550 - 18446744073708558550 18446744073708558551 - 18446744073708558551


What's this crap??


-------------Problems Reply------------

atoi() returns int. If you need larger numbers, try strtol(), strtoll(), or their relatives.

atoi() returns (int), and can't deal with (long long). Try atoll(), or failing that atol() (the former is preferred).

You are printing signed integers as unsigned.

Category:c# Views:0 Time:2011-06-05
Tags: int

Related post

  • Problem with automatic numbering 2013-09-04

    I was having a problem with automatic numbering in Word 10, so turned it off through file-options-proofing. In hindsight, I think this document was corrupt. I am now working on a new document and despite turning autocorrect back on, it is not working

  • Problems with page numbers in Word 2007 2013-10-12

    I have been having some problems with page numbering in all my multi-section Word documents lately. I do know how to create sections, remove the link to previous sections in the header and footer, format the page numbers, etc. 1. When I format the pa

  • VBA Having Problems Identifiying Negative Numbers 2013-12-18

    I'm having a problem identifying which numbers are negative I have numbers like the following in a single cell. $668.00 R $32.00 O $32.00 O -$619.00 R $619.00 R They can either have an O or R after then and they can be positive or negative. For every

  • Problem detecting cyclic numbers in Haskell 2009-11-15

    I am doing problem 61 at project Euler and came up with the following code (to test the case they give): p3 n = n*(n+1) `div` 2 p4 n = n*n p5 n = n*(3*n -1) `div` 2 p6 n = n*(2*n -1) p7 n = n*(5*n -3) `div` 2 p8 n = n*(3*n -2) x n = take 2 $ show n x

  • Problems with prime numbers 2009-12-09

    I am trying to write a program to find the largest prime factor of a very large number, and have tried several methods with varying success. All of the ones I have found so far have been unbelievably slow. I had a thought, and am wondering if this is

  • MySQL ORDER BY numeric value problem with negative numbers 2011-02-22

    I am using a query which uses: ORDER BY score DESC; 'score' just holds numeric values, which can also be negative. They don't seem to be displaying in the correct order. The negative numers can appear above positive numbers. Does anyone know the quer

  • Probably problem with scanning numbers - C 2011-04-14

    Possible Duplicate: Program not doing what it should - C Hello, Following program only read numbers from input and do stop when rull is violated, but 1 big problem is that it doesn't stop reading numbers and worse, don't print on screen what it shoul

  • Problem in reading numbers 2011-07-04

    Hello friends i am a total beginner in c#. I want to read numbers in the following format 2 1 10 3 5 For reading 2 i have used Convert.ToInt32(Console.ReadLine()) method and successfully stored it. But for the next input i want to read the number and

  • Word 2007: problems inserting page numbers in separate section 2012-01-20

    I've followed the instructions for inserting page numbers in a separate section, but every time I delete the numbers in the first section (it's not linked to the second one), all page numbers in the second section, except for page 1, disappear. I'm q

  • Precision problems of real numbers in Fortran 2012-04-04

    I've been trying to use Fortran for my research project, with the GNU Fortran compiler (gfortran), latest version, but I've been encountering some problems in the way it processes real numbers. If you have for example the code: program test implicit

  • Problem inserting page numbers in Word when using Book Design Wizard 2012-01-17

    I posted a question about an hour ago and although I'm grateful for the two answers given, they didn't work. I am using Book Design Wizard in Word and the manufacturers now tell me that the BDW doesn't come with page numbers in the information pages

  • problems with page numbering in Word 2010 2012-01-30

    Hello, I am working on a manual and I have spent the majority of my day trying to figure out how to get the page numbering correct. I noticed that some of the pages show Odd page footer, when it really should be Even page footer. I don't know how to

  • Problems with Figure Numbering - Invisible / Missing captions 2012-08-06

    Hi there, I am in the process of creating a document with a fair number of figures - around 50. For this reason I have been using the add captions facility in Word to automatically update when I add a figure anywhere in the document. For some reason

  • Word 2003 problem with outline numbering 2012-10-20

    My outline heading numbering works until part way through the document when heading level 4 lists increasing numbers without re-starting appropriately after the next heading level 3. This is what I am getting ... 6.3.1 6.3.2 6

  • Problem displaying telephone numbers in some websites 2012-10-27

    When I open some websites with telephone numbers diplayed on them, the numbers flick on for a fraction of a second, then flick off again - sometimes so fast that it is impossible to read them. How can I fix this please? I am running Norton 360. -----

  • Problem with page numbering and fonts when merging to new publication in Publisher 2007 2012-12-19

    I am using catalog merge to make a directory for my womens club with their pictures and information. It works fine for merging the information but when I put in page numbers, it doesn't give the correct page numbers when saved as a .pdf. Also if merg

  • Problem with footnote numbering between Mac 2008 Word and PC 2010 Word 2012-12-22

    I have a question about a formatting problem between Word 2008 for Mac and Word 2010 for PC. When working on my dissertation in 2010 for PC, I set up section breaks so that I could allow footnotes to begin numbering again in each chapter (rather than

  • Problem with Bullet/Numbering 2013-02-01

    To Whom who can Fix This Problem: For some reason, and out of the blue, my bullet is doing something strange. Before, it worked well and I had no problem with it. But after some time (I don't remember when but around half a year ago?), there is this

  • Problems with page numbers at different heights in footers 2013-02-09

    I have a problem with a large document. The page numbers need to be in the footers at exactly the same place however some are 1.5 cm up and others 3cm. I have checked all margins throughout the document and they are exactly the same and I am completl

  • Problem with page numbering when inserting a cover page 2013-03-14

    I have a template that contains the following in the footer to give me page x of y page numbering: {PAGE \* Arabic \* MERGEFORMAT} of {NUMPAGES \* Arabic \* MERGEFORMAT} This works fine until I insert a cover page (using the Insert->Cover Page opt

Copyright (C), All Rights Reserved.

processed in 0.135 (s). 11 q(s)