ItsMods

Full Version: Getting the number after the point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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]);
}
(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? Troll

(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? Troll

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
  1. foo = 1.2345;
  2. 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
  1. foo = 1.2345;
  2. 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
(08-31-2011, 20:05)some_kid Wrote: [ -> ]
(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
  1. foo = 1.2345;
  2. 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
  1. foo = 1.2345;
  2. bar = foo - int(foo);
  3. num = int( bar * 100 );


?
C++ Code
  1. while (int(bar) != bar) {
  2. bar = 10 * bar;
  3. }


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).