Velocity Reviews > IF-free conception.

IF-free conception.

Eric Sosman
Guest
Posts: n/a

 02-16-2013
On 2/15/2013 8:23 PM, Evgeney Knyazhev wrote:
> -----------------------
> You are mistaken. `i2' is the result of an `<' operator,
> hence either zero or one. `!0' is 1, `!1' is zero. `!i2' is
> well-defined.
> ----------------------------------
> well, let's assume
>
> int i=0;
> i=!i;
> // then output: 0xffff

Not in C. Perhaps you have confused `!' with `~' -- they
are entirely different operators.

I suspect that either (1) you are not using C but some
C-inspired other language, or (2) you have not actually tried

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)d

Evgeney Knyazhev
Guest
Posts: n/a

 02-16-2013
James, this code about IF-issues, but not about whatever programming language. if you haven't bothered, it doesn't mean Others have no interest of. ;D

----

Ben Bacarisse
Guest
Posts: n/a

 02-16-2013
Evgeney Knyazhev <(E-Mail Removed)> writes:

> Ben, factorial was written Just for fun Actually, recursive
> functions are the Evil.

That may be, but your code was also slower than the simple recursive
version.

> About performance, Just compare two codes:
>
> 1st. if(a<b)a++;
> 2nd. a+=(a<b);

That was not the example you gave. Here it can be argued that the
second version is simpler and clearer, but your blog suggests complex
versions of simple code. If you don't have any data supporting the
changes, why post them?

--
Ben.

Ben Bacarisse
Guest
Posts: n/a

 02-16-2013
Evgeney Knyazhev <(E-Mail Removed)> writes:

> anyway, "i1=!i2" ain't suited because we need inversion ;D

So why is ! unsuitable?

> i1=0; // then i2==1
> i1=1; // then i2==0

Did you mean "when" in place of "then"? "Then" does not make sense here
because i1 = !i2 has no effect on t2.

--
Ben.

Evgeney Knyazhev
Guest
Posts: n/a

 02-16-2013
Eric, you can test solution, if you want + i'm here to answer how beast runs
-------

Eric Sosman
Guest
Posts: n/a

 02-16-2013
On 2/15/2013 10:22 PM, Evgeney Knyazhev wrote:
> Ben, factorial was written Just for fun Actually, recursive functions are the Evil. About performance, Just compare two codes:
>
> 1st. if(a<b)a++;
> 2nd. a+=(a<b);
> ---

How did *you* compare them, and what numbers did *you* get?

Stop making silly claims without evidence to support them.
Also, when (if!) you ever get around to making any measurements,
keep in mind that your measurements are valid only for the system
on which they were made, and only in the context in which they
were made. The fact that snippet S1 is faster/slower than S2 in
some micro-benchmark on Machine A implies little or nothing about
the state of affairs on B -- It doesn't even say much about how
S1 and S2 will perform on A in slightly different circumstances.

--
Eric Sosman
(E-Mail Removed)d

James Kuyper
Guest
Posts: n/a

 02-16-2013
On 02/15/2013 10:36 PM, Evgeney Knyazhev wrote:
> James, this code about IF-issues, but not about whatever programming language. if you haven't bothered, it doesn't mean Others have no interest of. ;D

Well, so far the only results you've gotten is corrections to your
mistakes about C, expressions of disgust, reported timings that
appropriate windows/C++ forums. I haven't seen any positive expressions
of interest in the idea.
--
James Kuyper

Evgeney Knyazhev
Guest
Posts: n/a

 02-16-2013
------------------
That was not the example you gave. Here it can be argued that the
second version is simpler and clearer
--------------------
Ben, blog gives only the very idea, but whole code is in the source.

that's from source:
----------------------------
dv=(child+1<end);
dv=(a[child]<a[child+1])*dv;
child+=dv;
----------------------------

+ a mess with pointers like from blog was done for experiment's sake only
pointer arithmetic needs to cast types, thereby it's severely wrong way for everything.
----

Evgeney Knyazhev
Guest
Posts: n/a

 02-16-2013
---------------
Stop making silly claims without evidence to support them.
Also, when (if!) you ever get around to making any measurements,
keep in mind that your measurements are valid only for the system
on which they were made, and only in the context in which they
were made. The fact that snippet S1 is faster/slower than S2 in
some micro-benchmark on Machine A implies little or nothing about
the state of affairs on B -- It doesn't even say much about how
S1 and S2 will perform on A in slightly different circumstances.
-----------------
Eric, you did ans your question Everyone, who wants, can make own tests. + i've not claimed method as panacea ;D

Evgeney Knyazhev
Guest
Posts: n/a

 02-16-2013
---------------------------------
Well, so far the only results you've gotten is corrections to your
mistakes about C, expressions of disgust, reported timings that
appropriate windows/C++ forums. I haven't seen any positive expressions
of interest in the idea.
---------------------------------
James, take it easy, Please no solution can be absolutely Ideal + i did explain where if-lessness could be preferable.