Page 1 of 1

Any computer programers on the forum?

Posted: Sat Apr 14, 2007 10:04 am
by ppyvabw
Are there any **** hot computer programing whizz kids on the forum. I need help with something. I'm using turbo pascal and I have a kinda basic knowledge. Don't even know if what I want to do is possible.

Posted: Sat Apr 14, 2007 12:10 pm
by dnb
I can muddle my way through Pascal. What do you want to do?

Posted: Sat Apr 14, 2007 1:38 pm
by ppyvabw
I need to define a 64 bit non negative integer and be able to use bitwise operations on it, for example SHL SHR, AND, NOt etc....... There are the 80x87 data types that has the comp definition, but the shr and shl and all them don't work on it. It also goes from -something to +something and don't know how the minus works. I want to be able to manipulate single bits quickly.

It's to have like a 64 bit boolean bit field type thing.

Posted: Sat Apr 14, 2007 9:51 pm
by dnb
-ve will be 2's complement. This is where the MSB is given a -ve weighting.
For example (in binary) 0111 = 7, 1000 = -8, 1100 = -4

You can define operators on a custom type in Delphi (Turbo pascal with VC++ like front end), but it's quite a lot of work.

If it were my problem, I'd make a new data structure with the 64 boolean fields stored as an array or link list and write access procedures to act on the data. These could even be defined to be infix operators if you were feeling enthusiastic. It'll take up a bit more space than your first idea, but the code will actually run a lot faster.

Posted: Sat Apr 14, 2007 10:00 pm
by katanaman
%77%68%61%74%20%74%68%65%20%66%75%63%6b%20%61%72%65%20%79%6f%75%20%6f%6e%20%61%62%6f%75%74

sorry couldn't resist, you can convert that to ascii to get the message lol

Posted: Sat Apr 14, 2007 10:23 pm
by dnb
Sounds like you need to try this...

http://www.notdoppler.com/theimpossiblequiz.php

Posted: Sat Apr 14, 2007 10:27 pm
by katanaman
LOL yes that makes about as much sense.

Posted: Sun Apr 15, 2007 12:11 am
by ppyvabw
I understood the first bit about the minus sign.

The thing is when i've defined this 64 bit thing, I need thousands of them. Isn't a boolean type variable a whiole byte, so thats 64 bytes already, times howver many plus what othe variables there are. I soon use up the alloted 64K

Can it be done in C any easier?

It's a program i need to write for uni, a bit like a game tree. I'm a bit challenged with computers so bare with me. I know enough to be able to do what i need to do and thats it.

Posted: Sun Apr 15, 2007 12:19 am
by dnb
Don't worry about the space requirements. A bool type does indeed take up a whole 8 bytes, but unless you're planning to use a 286 or a microcontroller it's not a big problem. (besides there's the "packed" operator for records in Pascal which sorts a lot of this out) Having 10 instructions to retrieve a bool value instead of 2 is a problem since this will cause your program to be 5 times slower.

The 64K you talk about sounds like you are aiming for some kind of micro...

Yes - it's MUCH easier in C. You can define a bunch of bytes as a type definition and quickly write a means of accessing each bit. It'll not be much more than 10 lines. And you get the advantage of it being stored in a sensible compact structure.
What's the degree? :)

Posted: Sun Apr 15, 2007 10:16 am
by ppyvabw
Phd in particle physics and applied maths. It's a problem to do with spin up, spin down states in a 1D lattice and renormailsation. I want to start of with as many lattice sites as possible, then repeadetly halve the number at least 8 times (hence the need for 64 bits because after 8 times, the whole data structure will be treated as one lattice site with certain rules to ascertain whether it is a spin up or spin down state)

Apparently pascal is limited to 64k variable space or suminc. Unless I use a dynamic list with pointers and stuff but then thats getting beyond my programming ability when im only limited by the ram in my computer.

Posted: Sun Apr 15, 2007 11:19 am
by dnb
I'm pretty sure the 64k doesn't apply to complex data structures (only to each element in there). I maintain that Pascal is a much friendlier language than C. Have you downloaded the trial version of Borland Delphi 7? I found it better than Turbo Pascal and you can get it for free - the only restriction is that you can't use it for commercial purposes.

It's usually worth the effort to use pointers and stuff. I have an example I can send you somewhere...

Posted: Sun Apr 15, 2007 2:44 pm
by ppyvabw
Thats why I prefer pascal. Its more dummy friendy. ile look for that thing. i aint using it for commercial purposes so im fine. thanks