network sites: arcadespot.com hey | games
+ Reply to Thread
Results 1 to 8 of 8

Thread: Double To Int

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    56

    Default Double To Int

    This can be used for anything if you want. It converts a double to an int for whatever reason you need. xD
    call with
    Code:
    Double2Int(double d)
    Code:
    int Double2Int( double _d )
    {
    	uint32*	pD = (uint32*)&_d;
    
    	uint32	s = pD[1]&0x80000000;
    	int	exp = ((pD[1]>>20)&0x7ff)-1023;
    
    	if( exp<0 ) return 0;				
    
    	int64 t0 = *((int64*)pD)&0x000fffffffffffffL;
    	t0|=0x0010000000000000L;
    	int shift = 52-exp;
    	t0 = t0>>shift;
    	if( s!=0 ) t0=-t0;
    	return (int)t0;
    }

  2.    
  3. #2
    Retired
    Join Date
    May 2010
    Posts
    4,568

    Default

    A double what for whatever I need?

    I think you're going to have to elaborate, if you don't mind.

  4. #3
    The Moogle
    Join Date
    Feb 2008
    Location
    Alabama
    Posts
    3,256

    Default

    There's like 4 people on this site that will get what this is.

    Int. = integer btw.







  5. #4
    Spotter got spotted!
    Join Date
    Oct 2009
    Location
    In that place with that thing..
    Posts
    371

    Default

    I think I might find this useful. Thanks!

    Quote Originally Posted by Psyko View Post
    A double what for whatever I need?

    I think you're going to have to elaborate, if you don't mind.
    It's a C++ function..




  6. #5
    Senior Member
    Join Date
    Sep 2008
    Location
    $PWD
    Posts
    251

    Default

    Quote Originally Posted by SpotterMan View Post
    It's a C++ function..
    It's a C function. Remember C and C++ are often used interchangeably.

  7. #6
    Spotter got spotted!
    Join Date
    Oct 2009
    Location
    In that place with that thing..
    Posts
    371

    Default

    Quote Originally Posted by Babcock View Post
    It's a C function. Remember C and C++ are often used interchangeably.
    Meh.. I'm only learning C++ now




  8. #7
    Elite Poster
    Join Date
    Oct 2009
    Location
    at my computer
    Posts
    464

    Default

    lol i just started learning C++ so i don't know how this works XD hopefully i get to a point where i can understand this fully



  9. #8
    Senior Member
    Join Date
    Sep 2008
    Location
    $PWD
    Posts
    251

    Default

    I like C better. C++ is really fancy when you start learning the advanced stuff.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts