Yes, I wrote that in the beginning of this thread. In the meantime, I've written a little more, but there's no need to repeat it here.MachineCode wrote:Oh please, that's no argument.Little John wrote:these two functions we can very easily write ourselves
IsOdd() and IsEven()
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: IsOdd() and IsEven()
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: IsOdd() and IsEven()
Yep, I've said my piece anyway. I won't continue the thread after this post.
BTW, you need a command that evaluates 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].
BTW, you need a command that evaluates 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].

Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: IsOdd() and IsEven()
No ^^, Sqr() uses the special ASM-Code: FSQRT which is 10 times faster than the function Pow()MachineCode wrote:Sqr() is there for our convenience and readabilityCode: Select all
Debug Sqr(9) ; Why should Sqr() exist when Pow() can do the job?Debug Pow(9,0.5)

So it makes your code faster.
IsOdd() and IsEven() are parts of this list:
IsPositive(), IsNegative(), IsNull(), IsPrime(), IsFibonacci(), IsPowerOfTwo(), ...
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: IsOdd() and IsEven()
And likewise, Fred's ASM versions of IsOdd() IsEven() would be way faster than any macro we could write.STARGÅTE wrote:No ^^, Sqr() uses the special ASM-Code: FSQRT which is 10 times faster than the function Pow()
So it makes your code faster.

Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: IsOdd() and IsEven()
Surely, you only need either IsOdd() - or - IsEven() since IsOdd(11)=true whereas IsOdd(10)=false
- if its neded at all of course
- if its neded at all of course
Ta - N
-
- User
- Posts: 24
- Joined: Mon Jan 14, 2013 8:01 am
Re: IsOdd() and IsEven()
The Sign() command does these.STARGÅTE wrote:IsPositive(), IsNegative()

-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: IsOdd() and IsEven()
....now that's a good idea.Tenaja wrote:Since most of them are done in Macros, maybe somebody can start a "standard" PB Macro library for "all of us" to use.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: IsOdd() and IsEven()
MachineCode wrote:BTW, you need a command that evaluates 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].

