| ||||||
| 2000/4/6 [Computer/SW/Languages/Perl] UID:17937 Activity:nil |
4/6 C vs. Java vs. Perl comparisons: |
| 2000/4/6-7 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages] UID:17938 Activity:very high |
4/5 How do I concatinate two integers together into a long. If I do
something like
(a << 32) | b then this will only work on little endian machines
but not on big endian machines. How do I make concatination
machine dependent?
\_ This will work on both little and big endian machines, if a
contains the high order bits. The question is, where do a
and b come from? If they're being read from a file or some
stream, that's where your endian dependency comes from.
\_ this is bullshit. first of all, on your machie, int's
are probably the same size as long's (this is to the original
poster). To the responder, show me a definition for how
\_ 64-bit Unixes define int as 32-bit & long as 64-bit.
little endian and big endian machines store 64 bit entities.
the way i'd do this is use what he has up there, but at the
beginning of my program, write a routine that asserts that
it's the right way of doing it, and abort() at runtime if
it's not the case.
\_ #ifs
\_ don't you mean independent?
\_ if they are unsigned, can't you do (a*(2^32))+b
\_ This is equivalent to the code above; both work.
or if you need it to work in every situation, you need to look
in limits.h to see the true sizes of an int and a long on your
system, as well as endianness, and work it for the different
situations, have fun.
\_ Well, not true. On a big endian machine, if shift left
a long (which was promoted from a 32-bit int) wouldn't
the lower order bits fall off the left side. A perfect
solution would be to barrel rotate one of the numbers
and OR them together which will guarantee that it will
always work but I know of no barrel rotate function in
the standard C libraries.
say you've promoted ABCD from 16-bits to 32-bits.
- big endian: 0xDCBA0000 << 16 = 0x00000000
- little endian: 0x0000ABCD << 16 = 0xABCD0000
\_ You moron. First of all, that's not promotion, that's
reinterpretation of bits. Second of all, endian-ness
works on the byte level, not the nibble level; so the first
byte of a little endian 0xabcd is 0xcd, not 0xdc. Big
endian systems are intolerant of lazy casting. That's where
your problem lies; it's not with the shift operator. -pld
\_ You moron. You've mixed up big-endian and
little-endian. Plus, endian-ness works on the byte
level, not the nibble level; so the first byte of a
little endian 0xabcd is 0xcd, not 0xdc. This should read
- little endian: 0xCDAB0000 << 16 = 0x0000CDAB
- big endian: 0x0000ABCD << 16 = 0xABCD0000
And both those are the same number. -pld
\_ moron? who's the moron. look in P&H A-48. The lower
order bytes (CDAB) are one the right side for
order bytes (CDAB) are on the right side for
a little endian machine so it should be the other
way around.
\_ Have fun the next time you look at a memory dump -pld
\_ This is incorrect. shift left treats the entire int
as a unit. The high order bits fall off, regardless of
endian-ness. You need to go read K&R again.
\_ Size of int is NBPW*8 in sys/param.h, or simply sizeof(int)*8.
BYTE_ORDER is defined in machine/endian.h. You can also use
ntohl() and others in that file.
\_ but endianness DOESN'T FUCKING MATTER. Try it. Come on
it is a simple c program. Now go compile it on a linuix box.
Now on a sun. Ohh look. See the pretty results. Idiot. |
| 2000/4/6 [Uncategorized] UID:17939 Activity:low |
4/5 Anyone know where I can find resources on getting a webcam to work
in Linux (Creative WebCamII parallel).
\_ http://www.on-line.de/~m.wientapper/webcam/webcam.html - danh |
| 2000/4/6 [Computer/SW/Languages/Java, Computer/SW/Languages/Perl] UID:17940 Activity:nil |
4/6 C vs. Java vs. Perl comparisons:
------------------
#include <stdio.h>
#include <stdlib.h>
int fib(int num) {
if (num==0 || num==1) {return 1;}
return fib(num-1) + fib(num-2);
}
main(int argc, char *argv[]) {
printf("%d\n", fib(atoi(argv[1])));
exit(0);
}
------------------
import java.lang.*;
class fib {
private static int fib(int num) {
if (num==0 || num==1) {return 1;}
return fib(num-1)+fib(num-2);
}
public static void main(String args[]) {
System.out.println(fib( (new Integer(args[0])).intValue() ));
}
}
------------------
#!/usr/local/bin/perl5
sub fib {
my($num)=@_;
if ($num==0 || $num==1) {return 1;}
return fib($num-1)+fib($num-2);
}
print fib($ARGV[0])."\n";
Conclusion: C is still the fastest. Java is not as slow as people
think it is. Perl is nowhere close to Java performance.
\_ I could an implementation on my TI-85 pseudo-BASIC that will kick
the crap out of any of those. Take an algorithms course. That's
the conclusion. |
| 2000/4/6 [Computer/SW/WWW/Browsers] UID:17941 Activity:high |
4/6 http://www.csua.berkeley.edu/~danh/slideshow \_ http://nt2.amateur-pages.com/nicole/assets/images/Nicole036.jpg she's a web page designer \_ and how do you know that's not a stolen photo? they do that joo know... \_ of course it must be true if i read it on the internet! I also believe everything in the Penthouse Pet Bios! |
| 2000/4/6-7 [Computer/SW/Languages/C_Cplusplus] UID:17942 Activity:very high |
4/6 C vs. Java vs. Perl comparisons:
Conclusion: C is still the fastest. Java is not as slow as people
think it is. Perl is nowhere close to Java performance.
\_ Apples, Oranges, Bananas, and Trolls who like to delete
\_ Multithreaded java with native threads with a
decent rt gives you functionality that you can
only dream about in perl and groan about in C.
Debugging a multithreaded java server is much
easier than an equivalent c/c++ server. If
I'm running in an enviroment where CPU cycles
are important, c/asm is the only choice, c++
perl and java don't even enter the picture.
In every other environment the easy of development
and maintenance overrides speed concerns.
If you are concerned about performance
get better algorithms.
postings, look only at implementation languages and not the
entire problem to be solved. -- tmonroe
\_ What about php4?
\_ who mentioned web application development?
\_ You're right. Compiled perl is much faster than java.
\_ Multithreaded java with native threads with a decent rt gives you
functionality that you can only dream about in perl and groan
about in C. Debugging a multithreaded java server is much easier
than an equivalent c/c++ server. If I'm running in an enviroment
where CPU cycles are important, c/asm is the only choice, c++ perl
and java don't even enter the picture. In every other environment
the easy of development and maintenance overrides speed concerns.
If you are concerned about performance get better algorithms.
\_ How exactly is c faster than c++?
\_ Formatting widened.
\_ c++ has more language overhead if you classes/exceptions/op.
overloading. Also the binaries for a c++ app are larger than
those of a c app. In a severly memory/cpu constrained env.
c is better than c++ in terms of size (smaller ex. image) and
speed (less instr. to execute for straight c vs. c++ using
objs.)
\_ this is completely false. the only execution overhead
you'll see in c++ is from virtual dispatch, which ONLY
happens with virtual functions. there is NO overhead
in overloaded functions (unless virtual), none in using
class's instead of structs. there is overhead in using
exceptions, yes. but the rest of your comment is full
of shit. and the only reason why your executables might
be bigger is because symbol names are longer in c++,
so unstripped binaries will be larger. if you don't
know what you're talking about, say so in your post,
please, so people won't go around spreading your
shit. oh, if you want to talk about code bloat, you
ought to be mentioning templates, not the crap you
\_ on the other hand, I think Larry Wall or some high mucky-muck
has been quoted as saying "dont byte-compile perl, its broke"
\_ Perl is normally byte-compiled every time you run it.
\_ gimme a breakhere.i'm trying to differentiate between
"compiling perl" as in "installing", vs
"precompiling your perl" forspeedgain, as hinted at by
the above poser
\_ He didn't mean "installing" and you don't deserve a
break, loser. You're probably the same idiot who made
the "c is faster than c++" comment.
\_ I (the "idiot" in question) did not make this comment.
\_ Apples, Oranges, Bananas, and Trolls. -- tmonroe
\_ I could an implementation on my TI-85 pseudo-BASIC that will kick
the crap out of any of those. Take an algorithms course. That's
the conclusion.
\_ Yeah, according to algorithms course radix sort should run
faster than quick sort on large data sets. That is, until
you take CS 252 and actually run the algorithms do you find
out otherwise.
\_ They're defined recursively, but you don't want to compute them
that way...
\_ PEOPLE! JESUS FUCKING CHRIST, LEARN PROPER ENGLISH!
\_ what's wrong?
mention. but then, most people don't know how to use
templates so they don't use them. -ali.
\_ I heard that you almost never need to write your
own templates since the standard and useful ones
are usually already supplied by the development
environment. Is that true?
\_ I though that an object in c++ contained a copy
of each of its parent classes, thus a class
requires more memory to store than a struct.
\_ gee, in C,
struct A {... };
extending things are in C, without requiring
struct B { struct A a; ... }
struct B is pretty damn big too.
i don't understand what you're asking. if you
want to argue "C++ hides the fact that things
get large by making it easy to bloat your code
with only a few keystrokes" i might concede,
but i don't see what the alternative way of
extending objects are in C, without requiring
identical bloat. -ali
\_ YOU ARE BLOATED, ALI
\_ man, give ali a break, he's a
good guy - ali #2 fan |
| 2000/4/6-7 [Finance/Investment] UID:17943 Activity:nil |
4/6 What exactly does it mean when Dow/NASD is up/down by X points?
Is there an actual equation (e.g. sum(all shares*value)/companies
multiplied by a constant) or it is a measurement of something else,
like volume+share???
\_ See http://quote.yahoo.com/q?s=@^dji for DJIA components. The
DJIA is the weighted sum of these components, scaled to a reference
point of 100 some time in the 1920's. I don't know the weights of
the individual component. The NASDAQ Composite Index is similar.
the individual components. The NASDAQ Composite Index is similar. |
| 2000/4/6-9 [Computer/SW/Languages/Perl] UID:17944 Activity:high |
4/6 I wonder how many bugs will come out once time hits 0xDEADBEEF?
\_ 0xFEEDFACE of 0xCAFEBEEF with 0xDEADBABE
\_ the fun one will be sep 9 2001. the ascii representation of
a time_t will roll from 999999999 to 1000000000, and thousands
of lazy perl hacker code will sort lexicographically and launch
the nukes. --aaron
\_ Damn, why the hell do people (like the guy below) like to tab
so far out. What I'm curious about is what will happen to
computers once 2^32 seconds have passed by since 1970 (which
should happen around the year 2106). What will happen then?
Will the world predict a Y2.106K bug that will end the world
again?
\_ I thought that time_t wraps around in 2037.
Anyway, if we are still alive we should all
be using 128 bit or larger processors if not
quantum computers, meaning that time_t won't
wrap for several billion years (?).
\_ you must have this much clue to post to the
motd...
Hey wait, how did you get there. Go back to
your basement or something and stop talking outta
your ass.
\_ It doesn't seem likely that lazy perl code would do this;
if you are using "<" and ">" perl will treat the scalars as
numbers. You'd have to be explicitly using "gt". -tom
\_ He said sort. Perl sort defaults to cmp, not <=>.
--dbushong
\_ (why does this keep getting deleted?) 0xdeadbeef is a negative number
for signed 32-bit ints. 0xdeadbeaf refers to sometime in 1952.
for signed 32-bit ints. 0xdeadbeef refers to sometime in 1952.
\_ What's so special about 1952? Was that the year dead beef
was invented?
\_ No, that's what you get when you take 0xdeadbeaf and convert it
to a signed decimal (-559038737), and add that many seconds to
Jan 1, 1970. That's about 17 years and change. Hence 1952.
\_ well duh. I got that part. I'm saying what's so special
about 1952? That's like saying that 0xF00DF00D will take
us back 1879961613 seconds putting us 59 years back from
1970. Who cares?
\_ So what was the question? Do you really believe that
there was some cosmic conspiracy to choose Jan 1 1970 so
that 0xdeadbeef would be sometime in 1952? What are you
asking then?
\_ What's so special about 1921? Was that the year food
food was invented? |
| 2000/4/6-7 [Computer/SW/Languages/Java] UID:17945 Activity:nil |
4/6 In a big project, is it usually a good practice to try to use one
general purpose language for ease of maintenance and extensibility
(e.g. Java) or heterogenous environment (e.g. Java+C+Perl)?
\_ There is no one answer to this question. |