|
-
Apr 13th, 2007, 01:56 AM
#1
Thread Starter
Just Married
[RESOLVED] [2.0] Float
Hi all
Look that sub in the class
C# Code:
class cone
{
float ht, rd;
public void set(float h, float r)
{
ht = h;
rd = r;
}
}
C# Code:
cone c1;
c1=new cone();
c1.set(12.34,23.0);
ERROR HERE c1.set(12.34,23.0);
CAN NOT CONVERT DOUBLE TO FLOAT. WHY??
Last edited by shakti5385; Apr 13th, 2007 at 03:32 AM.
Reason: change vb code to c#
-
Apr 13th, 2007, 02:12 AM
#2
Re: [2.0] Float
"float" is an alias for Single. If you don't specify otherwise, any literal number with a decimal point in it is a Double. You cannot implicitly convert a Double to a Single because it is a narrowing conversion, i.e. data could be lost. If your method is expecting floats then you need to pass floats to it. To force a literal to type float you use an "F" suffix:
-
Apr 13th, 2007, 02:17 AM
#3
Thread Starter
Just Married
Re: [2.0] Float
 Originally Posted by jmcilhinney
"If your method is expecting floats then you need to pass floats to it. To force a literal to type float you use an "F" suffix
Thanks sir
It's working fine now.Can you give the list of more suffix in C# , that we have need to use in the code.
-
Apr 13th, 2007, 03:27 AM
#4
Re: [2.0] Float
What did your last slave die of? Look it up on MSDN, as you should ALWAYS do first. I think I may have mentioned that once or twice. Someone will take notice one day.
-
Apr 13th, 2007, 03:34 AM
#5
Thread Starter
Just Married
Re: [2.0] Float
 Originally Posted by jmcilhinney
Someone will take notice one day.
Today
Thanks sir
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|