Results 1 to 2 of 2

Thread: Make a program which takes in a whole number in the range 0 – 2147483647

  1. #1
    Join Date
    Oct 2011
    Posts
    1

    Make a program which takes in a whole number in the range 0 – 2147483647

    Make a program which takes in a whole number in the range 0 – 2147483647 and output the binary bit pattern for each of the following case:
    1. 32 bits: if the input number is stored as int.
    2. 32 bits: if the input number is stored as float.
    3. 64 bits: if the input number is stored as double.
    Look up the following web page to know details of double.


    i need this program please help!!!!

  2. #2
    Join Date
    Jan 2006
    Posts
    605

    Re: Make a program which takes in a whole number in the range 0 – 2147483647

    To get a number that is actually in the full range of an INT, you need to make two separate calls, and add them together. Then convert that unsigned INT value into a signed INT value.

    PHP Code:
    <?PHP
    // Returns negative numbers as if (-2147483647,0)
    $z mt_rand(0,2147483648);

    // Returns mostly 1 or negative numbers
    $z mt_rand(-2147483647,2147483647);

    // Returns negative numbers, but within range set???
    // So much for returning only values from 0 to Max
    $z mt_rand(-2147483647,0);

    // Attempt to stay within the range/spread of mt_getrandmax()
    // Results are odd, like 180 to 2147478000
    $z mt_rand(2147483647,4294967294);

    // Works, but it should not, as the value is not an INT
    // Values are converted to floor(x), so range is (0,0)
    $z mt_rand(0.000001,0.9999999);
    ?>

Similar Threads

  1. What is the program to print table of given number?
    By Roxy_jacob in forum Software Development
    Replies: 5
    Last Post: 04-09-2011, 10:40 PM
  2. Shell program to reverse a number
    By Bottlenecked in forum Software Development
    Replies: 5
    Last Post: 12-01-2010, 02:20 PM
  3. C sharp program for swapping number
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 31-12-2009, 02:55 PM
  4. Shell program for the prime number
    By Rup_me in forum Software Development
    Replies: 5
    Last Post: 14-12-2009, 10:24 AM
  5. Count the number of times yes appears in a range in excel
    By Andy Candy in forum Windows Software
    Replies: 3
    Last Post: 17-08-2009, 12:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,625,216.73920 seconds with 17 queries