Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Another C++ N00b


  • Please log in to reply
9 replies to this topic

#1 Patch-C

Patch-C

  • Members
  • 31 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Australia, Melbourne
  • Local time:12:21 PM

Posted 18 July 2007 - 03:23 AM

Hiya,

I'm another n00b and want to learn C++ i did a bit of VB.net at school and self taught a bit of Qbasic. I was just wondering if any could explain what these variable identifiers mean:

float
double
long double
wchar_t

I'm competent with Char, long, int, short from .net but have no idea about these


Cheers...

Patch

BC AdBot (Login to Remove)

 


m

#2 Glunn11

Glunn11

  • Members
  • 262 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Idaho
  • Local time:08:21 PM

Posted 18 July 2007 - 11:33 AM

Well, to get you started, a "float" is a number with decimal points, and wchar_t is a wide character.
I'm unsure of double and long double.

#3 Patch-C

Patch-C
  • Topic Starter

  • Members
  • 31 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Australia, Melbourne
  • Local time:12:21 PM

Posted 19 July 2007 - 01:06 AM

Thanks Man..

That makes perfect sense with the float but the w_char??

...

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:08:21 PM

Posted 19 July 2007 - 10:22 AM

Perhaps we should clarify that a bit more. A float is not necessarily a number with decimal points, nor is it the only option available for storing a decimal. A double will work quite nicely, depending on the amount of precision necessary. A float is a single precision , 32 bit number. It should never be used for currency. It also takes up less memory than a double, which is a double precision 64 bit integer. It should not really be used for currency either.

At any rate, a cursory explanation does not really tell you anything. To better understand what the differences are, and the uses, look at Primitive Data Types (it doesn't matter what language). And time spent on wikis would help you understand the difference between wchar and char, when to use which, or why either one should be used at all. Learning to program has precious little to do with whatever language you may be using. All of the data types have a background on why they are what they are; for example, if an int takes up 32 bits, what is the maximum possible value it can hold? Can you figure it out without looking it up? Do you understand how that value is obtained?

I'm competent with Char, long, int, short


What does that mean? That's sort of like saying I am competent in 'tree' and 'blue'. :thumbsup:

#5 Glunn11

Glunn11

  • Members
  • 262 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Idaho
  • Local time:08:21 PM

Posted 19 July 2007 - 07:32 PM

That's sort of like saying I am competent in 'tree' and 'blue'. :thumbsup:


I usually don't post dumb stuff like this but that is now stored away in my brain as a phrase to use when a situation comes up :D.

#6 Sixstringartist

Sixstringartist

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Location:Indiana
  • Local time:10:21 PM

Posted 24 July 2007 - 12:39 PM

My advice to you would be to find a recent used course book on C++ and use that with a good tutorial. Digging through wiki's isnt going to help much if they are not formatted in a tutorial type manner. Those are more for reference. Teaching yourself a new language can be very difficult. Try to get a structured approach to the language.

#7 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:08:21 PM

Posted 24 July 2007 - 05:56 PM

wiki's isnt going to help much if they are not formatted in a tutorial


Mostly this discussion is on primitive data types. I can't recall anything like "Floats in Five Easy Lessons" ever. And since data types are completely relevant in programming and almost never covered in tutorials, the only choice left is to go to the web and do some research. And since primitives are not language specific, the best choice is to go to the wikis, especially those that are computer science related.

Teaching yourself a new language can be very difficult

Especially when one is trying to learn programming concepts at the same time. :thumbsup:

#8 Sixstringartist

Sixstringartist

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Location:Indiana
  • Local time:10:21 PM

Posted 27 July 2007 - 10:23 AM

Mostly this discussion is on primitive data types. I can't recall anything like "Floats in Five Easy Lessons" ever. And since data types are completely relevant in programming and almost never covered in tutorials, the only choice left is to go to the web and do some research. And since primitives are not language specific, the best choice is to go to the wikis, especially those that are computer science related.

Apologies, I didnt mean to imply that a wiki wasnt a good resource for answering questions, rather I was under the assumption that you were recommending a wiki and a way to learn programming in general.

#9 Patch-C

Patch-C
  • Topic Starter

  • Members
  • 31 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Australia, Melbourne
  • Local time:12:21 PM

Posted 06 August 2007 - 05:39 AM

Damn!!

Thanks to all for this fab response.. I might get a book, but i'm getting it off a tut site CPlusPlus.net or something

I'm competent with Char, long, int, short

What does that mean? That's sort of like saying I am competent in 'tree' and 'blue'. smile.gif


What i probably should have said was that I understand what they mean... Char being any 'ascii' character (I'm pretty sure correct me it I'm wrong), Long being a large number to a very small number(long int), Int being a smaller range, and shore being (short int) the smaller range.

if an int takes up 32 bits, what is the maximum possible value it can hold? Can you figure it out without looking it up? Do you understand how that value is obtained?

A four digit number?? :thumbsup:" I am a n00b

Patch,,

#10 Martijnc

Martijnc

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:03:21 AM

Posted 06 August 2007 - 06:21 AM

if an int takes up 32 bits, what is the maximum possible value it can hold? Can you figure it out without looking it up? Do you understand how that value is obtained?

A four digit number?? :thumbsup:" I am a n00b


It is quite simpel: a bit can have 2 values (1 and 0), and a int contains 32bits so with some math:
2^32 = 4294967296

An integer can hold 4294967296 different values, going from -2,147,483,648 to 2,147,483,647 for a signed integer and 0 to 4,294,967,295 for a unsigned integer.

Edited by Martijnc, 06 August 2007 - 06:55 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users