Any computer programers on the forum?
Moderator: phpBB2 - Administrators
Any computer programers on the forum?
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.
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.
It's to have like a 64 bit boolean bit field type thing.
-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.
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.
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.
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.
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?
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?
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.
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.
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...
It's usually worth the effort to use pointers and stuff. I have an example I can send you somewhere...




