Results 1 to 3 of 3

Thread: Float Size

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024

    Float Size

    Maybe I am tired or something. But I cant figure out how to do this easily. If I have a float how can I tell its whole number size or places.

    Example:
    9 = 1 place
    93 = 2 places
    934 = 3 places
    9349 = 4 places
    93490 = 5 places
    and so on.

    I figure I could convert it to a string then get the length, but that seems like to much work. Anyone got a better idea?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Well I got this, unless someone has something better;

    Code:
    	float f = 1235.00;
    	float t = f;
    	int i = 0;
    	while(t >= 1)
    	{
    		t = t / 10;
    		i++;
    	}
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Don't know if taking the log to base 10 is better.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width