Is there a maths function in SCAR that equals True or False if a number is even or odd?
Thanks,
Rich
Is there a maths function in SCAR that equals True or False if a number is even or odd?
Thanks,
Rich
<3
Originally Posted by Eminem
I couldnt find any, so i whipped this together
You can edit to your liking.PHP Code:program NumberOdd;
var
Num : string;
Input : integer;
procedure DeclareNumberVar;
begin
Input := 15;//the number you want to check
end;
begin
DeclareNumberVar;
Num := FloatToStr(Input/2);
if(GetOthers(Num) = '.') then//this checks if its odd, because if its even the result will be a whole number
begin
Writeln(IntToStr(Input) + ' is an odd number');
end else
begin
Writeln(IntToStr(Input) + ' is an even number');
end;
end.
Hope its what you wanted,
no credit needed
Project: Welcome To Rainbow
mod.
SCAR Code:const
TheNumberYouWantToCheck = 4;
begin
WriteLn(BoolToStr(TheNumberYouWantToCheck mod 2 = 0));
end.
Modulus, I believe it's called.
"Script" above returns true/false depending on TheNumberYouWantToCheck is a even or odd number.
Scripts: Varrock Smither! | Fight Caves Runner! | Kebab Buyer! | L.A.M.E. (Outdated)
Tutorials: SRL user-defined procedures | JaGex UID files | Printing your scripts
Applications: StartUp Notepad | SCAR Assistant
Misc: FREE Delphi 7 v2 | Official SRL Graphics
EDIT: Never mind, I got it working. Thanks guys.
Benjaa, your's wasn't working, but I changed it to this and it did:
SCAR Code:program NumberOdd;
var
Num : Extended;
Input : Integer;
procedure DeclareNumberVar;
begin
Input := 1;//the number you want to check
end;
begin
DeclareNumberVar;
Num := (Input/2);
if(TrimNumbers(FloatToStr(Num)) = '.') then//this checks if its odd, because if its even the result will be a whole number
begin
Writeln(IntToStr(Input) + ' is an odd number');
end else
begin
Writeln(IntToStr(Input) + ' is an even number');
end;
end.
<3
Originally Posted by Eminem
No, it wasn't any errors...It was just that every number was claimed to be even.
<3
Originally Posted by Eminem
Oh yeah... I just tested again
It does come up all even
I must've copied the wrong script up... my bad, thanks for pointing that out
Silly me
EDIT:Should probably use GetOthers, instead of TrimNumbers as well
Project: Welcome To Rainbow
*feels totally ignored*
My point was that to check if a number is even or not, just mod it by 2.
Edit: Benjaa, I wasn't looking for creds. xD
Edit2: You people know that I was just joking, right ..?
Scripts: Varrock Smither! | Fight Caves Runner! | Kebab Buyer! | L.A.M.E. (Outdated)
Tutorials: SRL user-defined procedures | JaGex UID files | Printing your scripts
Applications: StartUp Notepad | SCAR Assistant
Misc: FREE Delphi 7 v2 | Official SRL Graphics
Shh EvilChicken!
You're making my scripting look less important :P
Lol, i tried yours and it worked beautifully, well done. Here's some candy.
I looked up an ubern00b tutorial for it for myself, but i couldnt find one.
Ill stick to my non-simplified coding for now
But i love your work EvilChicken
Edit: Yes Of course i know you were joking evilchickenyour a legend
Project: Welcome To Rainbow
EC, you weren't ignored. Trust meh![]()
<3
Originally Posted by Eminem
There are currently 1 users browsing this thread. (0 members and 1 guests)