Search:
Type: Posts; User: bwkaz
Search:
Search took 0.09 seconds.
-
Hey, look, another Useless Use Of Backticks! :p Forget the backticks (especially when all they do is call echo), just use the value directly. ;)
In this case, the problem seems to be that when...
-
Well, the matrix multiplication algorithm looks like:
[ a b ] [ c d ] = [ ac+bg ad+bh ]
[ e f ] [ g h ] = [ ec+fg ed+fh ] Now, I don't see any way to simplify this to three instructions -- at...
-
As long as *_a + *_b <= INT_MAX, anyway... ;)
Er, well, wait, maybe it would still work.
...
...
Yeah, it would, as long as *_a and *_b are both positive. If they're negative, you can...
-
fd = open("/dev/mem", O_RDWR);
/* do stuff with fd */ Alternately:
char *ptr = malloc(however_much_you_need);
/* do stuff with ptr */ since all memory is "protected" as far as the Intel...
-
*involuntary shudder*
:p
Instead of using a floating point math function, here's what I'd do:
unsigned char p = (unsigned char)(1 << i); ;)
-
Well, I won't do this, because I have a few other things going on at the moment, but it shouldn't be too hard to do. You should only need the Xtst libraries, and the <X11/Xtest.h> includes. Then...
-
Well... maybe, but it's not "code" per se. It's just one enormous regular expression that's meant to be applied to a string to determine whether the string is a valid RFC-822 address. AFAIK there...
-
Maybe, but I don't think there's any way I'll ever be able to decipher this one:
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
:p
-
Hrmm, let's see...
sed -e 's/[[:space:]]/\n/g' file.txt | sed -e 's/[^A-Za-z]//g' | cut -c 1 perhaps?
-
psych-major:
find /path -name '*.mp3' >file.m3u
will work, as long as none of the filenames or directories have newlines in them. (Which is actually legal in filenames, but I doubt that the...
-
I really should.
It might make it "easier", but there's the minor detail of how it also makes it "wrong". :D (At least, "wrong" in terms of what I believe the C++ committees want. I could be...
-
So in other words, you "factor" ax^3 + bx^2 + cx + d into:
(((ax + b)x + c)x + d
It's not a true factorization, but it does reduce into n multiplications.
(FWIW: This question was asked so...
-
-
:D
I can do it without an if, but I need a dummy variable:
int y = ((int)(x & 0x800000000u)) >> 31;
/* y is all 1 bits now if x was negative, and 0 otherwise */
x ^= y; /* either...
-
Well, actually no, I'm not positive.
But the jump table would be absolutely gigantic with a switch that looks like this:
switch(tempvar) {
case 0: break;
case INT_MAX: break;
}...
-
Um... no it isn't... ;)
First, it would require, at MINIMUM, 16 billion gigabytes of code space (since it'll be at least one byte for each value of a and b, that's 4 billion, squared,...
-
Well, you didn't say what language, I guess...
#!/bin/sh
if [ $# -ne 1 ] ; then
echo "Usage: $0 filename"
exit 1
fi
-
And make sure that the argument to ceil() is a float or double, not an integer. In other words, this:
int x = 5, y = 22;
printf("%lf\n", ceil(y/x)); won't work, it'll print 4. The reason is...
-
Aww, come on! I want to yell at you about it! (... or, uh, something...)
:p
http://rhols66.adsl.netsonic.fi/era/unix/award.html ;)
-
You don't even need to use cat for that (this is one of the Useless Uses of Cat, congratulations! :p)
You can do this instead:
sed -e 's/[TAB]/[3 SPACES]/' <$file >$newfile
Or, better yet,...
-
Strike: you don't even need the range(int(math.sqrt(10000))). The square root of 10000 is 100, so you can just use range(100). :p
(Of course, this doesn't negate the fact that x**2 is...
-
Yep, there's a dynamic programming algorithm to do it.
I don't remember what that algorithm is, of course ( :eek: ), but I do remember that it exists...
-
#!/bin/bash
/usr/bin/wc "$@" You just have to give it the right options... ;)
-
Sure, just factor it.
Oh, wait... not all polynomials factor... :p
int sum(int num1, int num2)
{
int result = 0;
int i, carry = 0;
-
( a + ib ) * ( c + id ) = ac - bd + i ( ad + bc )
So, I don't think I can figure a way to do it in less than four multiplications...
Hmm, maybe this:
( a + ib ) c + ( a + ib ) id
But...
|
|