GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Feb-2005, 21:59
CeSu-Pro CeSu-Pro is offline
New Member
 
Join Date: Feb 2005
Posts: 6
CeSu-Pro is on a distinguished road

using Floats and Parse'


i am building a project to determine the maturity value given certain variables.

I have these lines in my project,

CPP / C++ / C Code:
float Inter;
Console::Write(" Please Input your expected Interest and press <enter>:");
	Inter = Float::Parse(Console::ReadLine ());

but when i build it brings up the following errors,

'error C2653: 'Float': is not a class or namespace name' and
'error C3861: 'Parse': identifier not found, even with argument-dependent lookup'

When i change 'Float' to 'Int32' it works up until the point where you have to put in the interest which is
not an integer so it causes problems...


any help would be great. Thank you.
Last edited by LuciWiz : 14-Feb-2005 at 01:18. Reason: Please insert your C code between [c] & [/c] tags
  #2  
Old 14-Feb-2005, 01:23
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 890
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough
I am confused. It seems to be C# judging by the Data types and methods, but you use the "::" operator like in C++.
Anyway, I'll consider it C# - and I will move the thread to the appropriate forum (the .NET Forum ) as soon as you confirm reading my post.

There is no Float class in C#, only float. Use this:

CPP / C++ / C Code:
//C# code
	float Inter;
	Console.Write(" Please Input your expected Interest and press <enter>:");
	Inter = float.Parse(Console.ReadLine());

Best regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #3  
Old 17-Feb-2005, 20:46
CeSu-Pro CeSu-Pro is offline
New Member
 
Join Date: Feb 2005
Posts: 6
CeSu-Pro is on a distinguished road
it actually was C++ code,.... i am new to programming and taking an intro class... part of the code was directly from the teacher,... he later gave a hint to use floats instead of ints.... but i could not get it to work with Float or float... so i ended up using Double and it worked fine... Thank you for the reply tho,...just wanted to explain to you what happened. (and thanks for editing my post for me)

Thanks for any more help in advance.
  #4  
Old 18-Feb-2005, 01:12
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 890
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough
Aha - Managed C++ then!
The data types were obviously from the .NET Framework, I just didn't meet many people using the controversial Manged C++. Fine then, I'll still move it to the .NET Forum

Anyway, there is no Float in C++ either, only float or FLOAT, which is actually a typedef from float (so it is actually the same thing).

In order to call Parse on a single precision floating number you need to use the System.Single structure. Confusing, I know...

So, in the light of the new events, your code should be something like this:

CPP / C++ / C Code:
	//Managed code
	float Inter;
	Console::Write(" Please Input your expected Interest and press <enter>:");
	
	//Inter = float::Parse(Console::ReadLine());
	Inter = Single::Parse(Console::ReadLine());
	
	Console::Write(S"The input data is ");
	Console::WriteLine(Inter.ToString());
	Console::ReadLine();

I hope this works well for you, and you are welcomed to post more questions on this topic, since there is little input on Managed C++ on the forums right now.
After you confirm reading this, I will move this thread to the right forum.

Kind regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #5  
Old 18-Feb-2005, 17:58
CeSu-Pro CeSu-Pro is offline
New Member
 
Join Date: Feb 2005
Posts: 6
CeSu-Pro is on a distinguished road
Thank you very much for your help... I've been to too many forums where the more experienced users just make fun of those who don't know as much, but i must say you have been very helpful.... I ended up using Double instead of Single (i think that allows more precision,....) Either way, thank you very much. And i will be sure to ask when i get stuck again.
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:05.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.