# Thread: [release] Round up function

1. ## [release] Round up function

This is used to round a non-whole number into a whole number.

you would use it like so.

self.newvale = Round_it("5.7");

this would make self.newvalue == 6

Code:
```Round_it( number )
{
numer = strtok( number, "." );
if( numer[1] >= 5 || numer[1] >= 50 || numer[1] >= 500 || numer[1] >= 5000 )
{
numer[0]++;
}
else
{
numer[0]--;
}
return (numer[0]);
}```

0

2. tony, do you mind teaching me about strtok? I have no idea how to use it and what it's used for.

0

3. Originally Posted by MorderVonJuden
tony, do you mind teaching me about strtok? I have no idea how to use it and what it's used for.
no problem ill sum it up real quik.

numer = strtok( "option 1|option2|option3, "|" );

the first part of strolok that i filled with option 1-3 are variables that are seperated by a symbol, it takes these options and adds it to a array

so it would become
numer[0] = "option1"
numer[1] = "option 2'
and so on, you can use any symbol as long as you specify that symbol in the last field ( "|" )

0

4. Originally Posted by tony
no problem ill sum it up real quik.

numer = strtok( "option 1|option2|option3, "|" );

the first part of strolok that i filled with option 1-3 are variables that are seperated by a symbol, it takes these options and adds it to a array

so it would become
numer[0] = "option1"
numer[1] = "option 2'
and so on, you can use any symbol as long as you specify that symbol in the last field ( "|" )
I still don't get it..
can you put a detailed tut up for me?

0

5. Originally Posted by MorderVonJuden
I still don't get it..
can you put a detailed tut up for me?
i will let me switch to my tablet

0

6. Originally Posted by MorderVonJuden
I still don't get it..
can you put a detailed tut up for me?
The character you put at the end of the strtok is used to separate the options in the first part of the strtok, so if I put strtok( "dicks/dicks1/dicks2", "/" ) then it says when "/" is found, separate array or something like that. It like creates arrays from a list and uses a symbol to separate them.

0

7. Originally Posted by tony
i will let me switch to my tablet
Thanks bud!

0

8. This will also help me too because I know very little of this.

0

9. ## Re: [release] Round up function

i posted the tutorial

Sent from my Transformer TF101 using Tapatalk 2

0

10. This is a little script create by Killingdyl:
Code:
```roundUp( floatVal )
{
if ( int( floatVal ) != floatVal )
return int( floatVal+1 );
else
return int( floatVal );
}```
It should return an integer and accept an integer for the parameter.

0

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
All times are GMT -10. The time now is 07:22 AM.