Raised This Month: $51 Target: $400
 12% 

Remove first 4 digits of integer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Porcellian
Member
Join Date: Oct 2017
Old 03-05-2021 , 13:03   Remove first 4 digits of integer
Reply With Quote #1

Hello,

I have an integer called Match.

Match = 100025

How do I remove the first 4 digits of the integer, so that Match = 25

Kindest Regards
Porcellian is offline
Sarrus
Member
Join Date: May 2020
Location: France
Old 03-05-2021 , 13:23   Re: Remove first 4 digits of integer
Reply With Quote #2

Code:
Match = Match - (Match/100000)*100000
The / operator is the euclidian division
__________________
Discord Coding Server | Steam Profile | Community Website | Github Profile

Taking paid requests (add me on Discord)
Sarrus is offline
Porcellian
Member
Join Date: Oct 2017
Old 03-05-2021 , 13:51   Re: Remove first 4 digits of integer
Reply With Quote #3

That really didn't work. Just tried it and the result is 0?
Porcellian is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-05-2021 , 15:20   Re: Remove first 4 digits of integer
Reply With Quote #4

?

PHP Code:
// range -99 - 99
Match Match 100
__________________
Do not Private Message @me

Last edited by Bacardi; 03-05-2021 at 15:21.
Bacardi is offline
Sarrus
Member
Join Date: May 2020
Location: France
Old 03-05-2021 , 18:53   Re: Remove first 4 digits of integer
Reply With Quote #5

Quote:
Originally Posted by Porcellian View Post
That really didn't work. Just tried it and the result is 0?
Just tried it and it worked, try to run this:

Code:
public void OnPluginStart()
{
int match = 100025;
match=match-(match/100000)*100000;
PrintToServer("%d", match);
}
Bacardi's solution is way nicer however.
__________________
Discord Coding Server | Steam Profile | Community Website | Github Profile

Taking paid requests (add me on Discord)

Last edited by Sarrus; 03-05-2021 at 18:56.
Sarrus is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-06-2021 , 12:55   Re: Remove first 4 digits of integer
Reply With Quote #6

The proper way is to use modulus ( Match % 10000 )
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-06-2021 at 12:58.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 13:11.


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