| View previous topic :: View next topic |
| Author |
Message |
Benji Random spam moderator
Reputation: 4
Joined: 31 Dec 2007 Posts: 61 Location: The Netherlands
|
Posted: Mon Aug 03, 2009 9:28 am Post subject: Need help with C++ |
|
|
What is the difference between Float, String, Char, Int, Signed, Unsigned, Shorts and Longs? The tutorial is very unclear about them and the only thing I can understand from it is that they can hold a certain capacity of numbers.
Also, not just their meanings. I'd like a full explanation. Will +REP.
_________________
Last edited by Benji on Mon Aug 03, 2009 10:16 am; edited 3 times in total |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Mon Aug 03, 2009 9:35 am Post subject: |
|
|
they're different data types
float = non-integer
string = look it up.. i'm not even going to explain that one
char = character.. ?
int = integer
signed = can be negative
unsigned = positive/0
|
|
| Back to top |
|
 |
DURAN Newbie cheater
Reputation: 14
Joined: 19 Apr 2007 Posts: 16 Location: The Netherlands
|
Posted: Mon Aug 03, 2009 9:44 am Post subject: |
|
|
| where's the cp?
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Mon Aug 03, 2009 9:48 am Post subject: |
|
|
Refer to this http://en.wikipedia.org/wiki/Integer_(computer_science)
This is what char looks like in the memory
| Code: | | 00402258 6C 6F 6C 6F 6C 6F 6C 6F 6C 00 lolololol. |
This is what string looks like in the memory
| Code: | | 0013FF14 6C 6F 6C 6F 6C 6F 6C 6F 6C 00 lolololol. |
Not much, but both of them have a \0 terminator... Correct me if I'm wrong but, string is used only in C++ because C++'s iostream lib.
If you want to use integers above long(signed or unsigned), you could do...
| Code: |
unsigned long long wat = 84793292932432432;
signed long long wat = -84793292932432432;
|
|
|
| Back to top |
|
 |
Jonyleeson Master Cheater
Reputation: 0
Joined: 03 May 2007 Posts: 484 Location: Hérault, France
|
Posted: Mon Aug 03, 2009 9:53 am Post subject: |
|
|
| ; wrote: |
This is what char looks like in the memory
| Code: | | 00402258 6C 6F 6C 6F 6C 6F 6C 6F 6C 00 lolololol. |
|
No, that's what an array of chars, also known as a string, looks like in the memory. A char itself is just a signed byte.
_________________
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Mon Aug 03, 2009 9:55 am Post subject: |
|
|
| Jonyleeson wrote: | | ; wrote: |
This is what char looks like in the memory
| Code: | | 00402258 6C 6F 6C 6F 6C 6F 6C 6F 6C 00 lolololol. |
|
No, that's what an array of chars, also known as a string, looks like in the memory. A char itself is just a signed byte. | That's what I meant.
|
|
| Back to top |
|
 |
Benji Random spam moderator
Reputation: 4
Joined: 31 Dec 2007 Posts: 61 Location: The Netherlands
|
Posted: Mon Aug 03, 2009 10:17 am Post subject: |
|
|
So why wouldn't you always use a long int or w/e? And what are they actually good for?
_________________
|
|
| Back to top |
|
 |
Ind3siszive Cheater
Reputation: 0
Joined: 23 Apr 2009 Posts: 43 Location: in a glitch
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Mon Aug 03, 2009 10:52 am Post subject: |
|
|
| Benji. wrote: | | So why wouldn't you always use a long int or w/e? And what are they actually good for? | http://www.programmersheaven.com/user/pheaven/blog/191-Float-Double-and-Decimal-do-you-know-the-differences/
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Mon Aug 03, 2009 1:33 pm Post subject: |
|
|
| Quote: | | What is the difference between Float, String, Char, Int, Signed, Unsigned, Shorts and Longs? The tutorial is very unclear about them and the only thing I can understand from it is that they can hold a certain capacity of numbers. |
Float.
Contains a "floating" decimal point - used for exact measurements for things such as 3D rendering in DirectX, OpenGL, etc.
While setting these you typically append an "f" to the number.
__________________________________________________________
Char.
A single byte in memory (BYTE is typedef'd as an unsigned char), ranging from 0-255 (0x0 - 0xFF). Can store regular numbers as bytes, or ASCII characters whose values will be stored. Most common disassemblers/memory editors/hex viewers will show you this ASCII in plain text.
___________________________________________________________
String.
A C++ container that is basically used to handle a series of char's, ending with a NULL-terminated character (aka "\0").
The object has special functions that make it easier to manipulate itself, as opposed to simple char buffers, which need the basic "str"-funcs to handle it. (or just plain byte value changing by yourself).
___________________________________________________________
Int.
A regular int will usually be automatically signed. Integers hold number values in memory.
Signed (have a "sign" such as negative or positive) = –2147483648 to 2147483647
Unsigned (can only be positive) = 0 to 4294967295
Same range size, but not the same range.
Integers are typically 4 bytes, although it depends what system you run on.
___________________________________________________________
Long.
4 bytes, aka DWORD.
Unsigned long or signed long = unsigned int or signed int.
___________________________________________________________
Short.
Only 2 bytes, aka WORD.
Ranges:
signed short = –32768 to 32767
unsigned short = 0 to 65535
|
|
| Back to top |
|
 |
Benji Random spam moderator
Reputation: 4
Joined: 31 Dec 2007 Posts: 61 Location: The Netherlands
|
Posted: Mon Aug 03, 2009 5:06 pm Post subject: |
|
|
I'm following that exact tutorial, but I'm not English so I have a trouble understanding the meanings.
Sorry, but you will have to wait 36658 seconds before you can give rep
Thank you
_________________
|
|
| Back to top |
|
 |
|