Thread: limits.h

  1. #1
    kostas
    Guest

    Question limits.h

    how can i change the defined values of types on limits.h? i particuraly want to increace the value of unsgned long int if i can. thanks.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >i particuraly want to increace the value of unsgned long int if i can
    Why? I'm very sure that what you think you want isn't actually what you want. If you need a larger data type than an unsigned long int, use a long double and kill the decimal.

    -Prelude
    My best code is written with the delete key.

  3. #3
    kostas
    Guest
    i want to know if it is possible.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Of course it is, simply change the limits.h values. But trust me when I say that this is not what you want.

    -Prelude
    My best code is written with the delete key.

  5. #5
    kostas
    Guest
    i have done this already but it doesn't work. i wnt to print int value greater than unsigned long int.

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    Then you will have to get a 64bit system. a 32 bit int is always a 32 bit int no matter what the limit.h says.

    Why do you need to print int values. Any reason double wont work?

  7. #7
    kostas
    Guest
    i wiil try it. i use to print double or long double %u?

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Code:
    #include <stdio.h>
    #include <limits.h>
    
    int main ( void )
    {
      double d = 1234567898765432.0;
      printf ( "%.0f\n%u", d, ULONG_MAX );
      return 0;
    }
    -Prelude
    My best code is written with the delete key.

  9. #9
    kostas
    Guest
    i made a programm that calculates prime numbers that are less from a number the user give. so i had an idea of giving him to put up to the number 10.000.000.000. but i had that problem. with a pentium 2 i have that would take a week to calculate the numbers.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > with a pentium 2 i have that would take a week to calculate the
    > numbers.

    Oh, here's an easy fix. Change your user input prompt to read:

    "Enter two numbers, and come back in a week:" (for the humor impared, think "Take two of these and call me in the morning...")


    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >so i had an idea of giving him to put up to the number 10.000.000.000.
    Good idea, I find the need to know all of the primes between 9,000,000,000 and 10,000,000,000 on a daily basis.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using limits.h
    By cleepy in forum C Programming
    Replies: 44
    Last Post: 11-06-2008, 02:25 PM
  2. limits.h problem!!
    By guitarist809 in forum C++ Programming
    Replies: 21
    Last Post: 04-13-2006, 10:28 PM
  3. need header files (limits.h and float.h)
    By Sapphire19 in forum C Programming
    Replies: 3
    Last Post: 11-06-2001, 05:59 PM