Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Getting the number after the point
#1
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]);
}
[Image: MaEIQ.png]
Reply

#2
(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-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#3
(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

[Image: MaEIQ.png]
Reply

#4
(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
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#5
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);
Reply

#6
(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
Reply

#7
(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 );


?
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#8
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).
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Question Help Upgrade my point system from files to Database, help? EnVi Sweden Rocks 11 8,722 08-03-2013, 23:31
Last Post: EnVi Sweden Rocks
  Help Icon/point on radar 8q4s8 2 2,627 05-06-2013, 16:49
Last Post: 8q4s8
  Your phone number? kokole 10 5,264 01-18-2013, 19:59
Last Post: JariZ
  Point system Killer_xD 10 6,086 08-01-2012, 08:19
Last Post: Pozzuh
  New DLC Available: Jagged Alliance - Back in Action: Point Blank DLC Steam 0 1,936 06-22-2012, 12:48
Last Post: Steam
Sad Petition to remove Rendflex's 10 point warning JariZ 3 2,595 06-04-2012, 19:04
Last Post: SuperNovaAO
  exceeded maximum number of child1 script variables xplosiff 6 7,209 01-07-2012, 11:46
Last Post: xplosiff
  [Tutorial] Custom Kill/Point Streak Function Tomsen1410 9 5,526 12-01-2011, 00:15
Last Post: JariZ
  Help point system Gamemaster20 3 2,083 10-21-2011, 06:01
Last Post: Lemon
Sad [Request] Weapon Change after certain Number of kills Scripts18 5 2,621 09-17-2011, 13:13
Last Post: Scripts18

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.