Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

35% FASTER MOTHERUCKERS

Name: Anonymous 2007-09-05 16:12 ID:sZSJ96Te

n & 1 is 35% FASTER HTAN n % 2
DISCUSS BRIFLY

Name: Anonymous 2007-09-05 16:15 ID:2n0MGtNe

40%, bitches!!!  WHERE THE FUCK ARE MY SUBS FOR 40%!???????????  ALSO RAWS!!!!!!!

Name: Anonymous 2007-09-05 16:23 ID:SP9Njc0g

DIVISION IS FUCKING SLOW

Name: Anonymous 2007-09-05 16:27 ID:sZSJ96Te

>>3
DIVISOON IS FNOT UFKC INGLSOW
% IS NOT DIVIOSN IT SA LOOP YOU FOCKIN BU0B
YOUF UCK
FUCK
5 %%% 5^^ ^
& IS FASTER BECASUE ITS TSTS

Name: Anonymous 2007-09-05 16:43 ID:VkDXc0Zd

Since I learnt division is slower than multiplication, instead of doing a / b I always do a * (1 / b)

Name: Anonymous 2007-09-05 16:46 ID:kpqVRpJE

thats the experience bar of razeres on its way to lvl 98 ?

Name: Anonymous 2007-09-05 16:51 ID:kVP8FtM8

IT IS THE DIFFERENTS BETWEAN IDIV AND AND INSTRUCTION MTOHERFUKKERS

Name: Anonymous 2007-09-05 16:54 ID:eU+eCb50

I use precalculated arrays because it's just that much faster

Name: Anonymous 2007-09-05 17:00 ID:Ca8uyot9

perhaps n % 2 is a bit more portable than n & 1 though.  The compiler should optimize it to the same thing if it can, really.

Name: Anonymous 2007-09-05 17:03 ID:Heaven

>>9
perhaps n % 2 is a bit more portable than n & 1 though.
False

The compiler should optimize it to the same thing if it can, really.
True

Name: Anonymous 2007-09-05 17:08 ID:w50UIpRl

the only dreason  why 4 $4n % %20
n5
n % 2 is portable mo than n %
^n
n^
n & 1 is when the language has  % monuduls but not %^
^
$
^
4$$6^&&*
&

Name: Anonymous 2007-09-05 17:10 ID:w50UIpRl

>>11
but them aigain were tlaking bout polymorphi

Name: Anonymous 2007-09-05 17:14 ID:Heaven

The difference is:
-1 % 2 == -1
This stupid convention has been around forever, preventing compilers from optimizing shitty code.

Name: Anonymous 2007-09-05 17:16 ID:VkDXc0Zd

>>13
+1 Insightful

Name: Anonymous 2007-09-05 17:21 ID:Heaven

>>14
slashdotfag

Name: Anonymous 2007-09-05 17:37 ID:eq0t1gUn

>>13
That shouldn't matter if you're just testing for truth.

Name: Anonymous 2007-09-05 17:43 ID:2n0MGtNe

x / 2?

MOAR LIEK x >> 1 M I RITE!!!?

DIVISION IS FUQIN SLOW!!!

Name: Anonymous 2007-09-05 17:55 ID:Heaven

>>17
What happens when x = -1?

Name: Anonymous 2007-09-05 18:11 ID:2n0MGtNe

>>18
EXPERT PROGRAMMERs use only unsigned integers, no floating points or other silly stuff like negative numbers.

Name: Anonymous 2007-09-05 18:51 ID:shW8/HmI

>>13
However if the code is just, like...
bool isodd(int x) { return (x % 2) != 0; }
Then it ends up being compiled to exactly the same as
bool mask_isodd(int x) { return x & 1; }

Still, something to know. When you need to remove that one division, hurr. After all it's not like L2 cache misses didn't cost about five or six divisions' worth of cycles already... oh snap.

Name: Anonymous 2007-09-05 19:05 ID:shW8/HmI

Also, just
int blah(int x) { return x % 2; }
compiles, with optimization, to a move, a shift, a "lea", an and and a sub; that's an instruction sequence with a 5-cycle latency. Far less than a division, which you'd require for a generic remainder operation. Not to mention that processors these days can interleave those 5 instructions among other stuff given either enough free registers (exactly the same number as for a div tho) or decoders that're far enough ahead of the execution stream.

So yeah. With C, it's best to state your intent and let the compiler figure it out. Which is why the (x % 2) != 0 thing compiles to a simple and, or I suppose inside an if statement to a test insn.

Name: Anonymous 2007-09-05 20:24 ID:NvbhUvo4

irb(main):004:0> -10.0 & 1
NoMethodError: undefined method `&' for -10.0:Float
        from (irb):4
        from :0

Name: Anonymous 2007-09-05 20:24 ID:NvbhUvo4

irb(main):005:0> -10.0 % 2
=> -0.0

Name: Anonymous 2007-09-05 21:19 ID:eU+eCb50

>>22,23
Why are you using floats? Everyone's using ints.

Name: Anonymous 2007-09-05 22:58 ID:NvbhUvo4

>>24
The point is to show that modulo works on real numbers (which floats try to emulate) while & doesn't

Name: Anonymous 2007-09-06 8:10 ID:Heaven

>>25
You probably shouldn't be checking floats for parity anyway.

Name: Anonymous 2007-09-06 9:56 ID:UgSPcWk2

>>26
He's checking to see if the number is odd or even. As floating point numbers include integers too, it's a valid check.

Actually this makes me wonder - how do you determine if a fractional or irrational number is odd or even, or is it undefined?

Probably you'd have to specify if the whole number part is odd or even. e.g. PI is odd, e is even, 5/2 is even.

Name: Anonymous 2007-09-06 10:20 ID:Oey+rR6i

>>22
>>23
Why on earth would you consider optimizing for a shit-slow language? Seriously. Ruby's runtime evaluates SYNTAX TREES for fuck's sake. It doesn't even have freaking common subexpression elimination, or dead code elimination.

Name: Anonymous 2007-09-06 10:42 ID:Oey+rR6i

>>27
Checking whether a real number is odd or even depends solely on the integer part. Therefore the correct method is (((int)f) % 2) != 0, rather than fmodf(f, 2) >= 1.0f.

Name: ​​​​​​​​​​ 2010-09-08 19:04

Name: Anonymous 2012-11-05 22:54

SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS

Name: Anonymous 2012-11-06 13:12

35% FASTER DUBS

Name: Anonymous 2012-11-06 14:41

>>33
9000% faster useless piece of shit

Don't change these.
Name: Email:
Entire Thread Thread List