Raised This Month: $ Target: $400
 0% 

Only display nums to right of decimal


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 09-07-2007 , 21:52   Only display nums to right of decimal
Reply With Quote #1

How can I only display the numbers to the right of the decimal point?

Last edited by hlstriker; 09-07-2007 at 22:01.
hlstriker is offline
johnjg75
Veteran Member
Join Date: Mar 2004
Location: Delaware
Old 09-08-2007 , 01:41   Re: Only display nums to right of decimal
Reply With Quote #2

PHP Code:
stock ExplodeStroutput[][], max_leninput[], delimiter )
{
    new 
nIdx 0nLen = (copycoutput[nIdx], max_leninputdelimiter ))
    while( 
nLen strlen(input) )
        
nLen += (copycoutput[++nIdx], max_leninput[nLen], delimiter ))
    return

-Then just make an output variable like numbers[2][10]
-Make the number to a string and put it in input and set max_len to the length of the number
- Set delimiter to '.'

It should look similar to this:
Code:
ExploadeStr(numbers,9,numbertoseparate,'.')
The string will be separated into two parts, the number before the decimal and the number after the decimal.
numbers[0] contains the numbers before the decimal
numbers[1] contains the numbers after the decimal

Then you can just convert the string back to a number if you need to.
__________________
johnjg75 is offline
Send a message via AIM to johnjg75 Send a message via MSN to johnjg75 Send a message via Yahoo to johnjg75
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 09-08-2007 , 02:23   Re: Only display nums to right of decimal
Reply With Quote #3

I thought about using a method like that at first, but then a friend figured this method out for me...

PHP Code:
new Float:totalTime 123.456789
new roundTime floatround(totalTimefloatround_floor);

// If you wanted 3 digits...*1000 and %03d and so on...
new decimals floatround(floatsub(totalTimefloat(roundTime)) * 100floatround_floor);
client_print(0print_chat"Decimal = %02d"decimals);

// That would print 45 
hlstriker is offline
Old 09-08-2007, 05:11
Lee
This message has been deleted by Lee.
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode