(08-31-2011, 14:10)Pozzuh Wrote: [ -> ]for @Tomsen1410
Code:
//iprintln("2.4 will be: " + Number_func(2.4));
//2.4 will be: 4
Number_func(num)
{
num += " ";
num = StrTok(num,".");
return num[1];
}
now it will return "4 "...
(08-31-2011, 14:11)iAegle Wrote: [ -> ] (08-31-2011, 14:10)Pozzuh Wrote: [ -> ]for @Tomsen1410
Code:
//iprintln("2.4 will be: " + Number_func(2.4));
//2.4 will be: 4
Number_func(num)
{
num += " ";
num = StrTok(num,".");
return int(num[1]);
}
now it will return "4 "...
What are you talking about?
(08-31-2011, 14:13)Pozzuh Wrote: [ -> ] (08-31-2011, 14:11)iAegle Wrote: [ -> ] (08-31-2011, 14:10)Pozzuh Wrote: [ -> ]for @Tomsen1410
Code:
//iprintln("2.4 will be: " + Number_func(2.4));
//2.4 will be: 4
Number_func(num)
{
num += " ";
num = StrTok(num,".");
return int(num[1]);
}
now it will return "4 "...
What are you talking about?
it will return the number + a space
If there isn't a native function to do so, just do this (I never coded any gsc and I just guess this works).
C++ Code
foo = 1.2345;
bar = foo - int(foo);
(08-31-2011, 14:24)SuperNovaAO Wrote: [ -> ]If there isn't a native function to do so, just do this (I never coded any gsc and I just guess this works).
C++ Code
foo = 1.2345;
bar = foo - int(foo);
I don't have a use for either one yet, but the difference is, @
Pozzuh 's version will return 4 and @
SuperNovaAO 's will return 0.4
C++ Code
while (int(bar) != bar) {
bar = 10 * bar;
}
To get 0 digits after the . after cutting the front of.
And yes, this is probably still faster than string manipulation since string manipulation the slowest thing possible is for computers (computers are made to calculate, not read).