|
You do realize that's a 39 digit number??
Console.WriteLine("The maximum value of float is : " + float.MaxValue.ToString("N"));
Console.WriteLine("The minimum value of float is : " + float.MinValue.ToString("N"));
Q2 Paul got.
Q3 has to do with how numbers are repesented in a fixed number of bits. Read (PDF)[^].
|
|
|
|
|
I realize it's a 38 digit number, I just wanted to know if I can see it displayed...
Jon
|
|
|
|
|
Maybe I miss-counted ... Nope, 13 groups of 3 digits. 39. In scientific notation, move the decimal point 38 places to the right.
|
|
|
|
|
I found an article which, in summary indicates that exponentials are calculated as the product of the value and base (usually 10) raised to the power of the exponential value.
So for example,
This is the Float value types
-------------------
The maximum value of float is : 3.402823E+38
This is equal to 3.402823 * (10 ^ 38)
The minimum value of float is : -3.402823E+38
The date is: 16/09/2007 09:01:59
This is equal to -3.402823 * (10 ^ 38)
Source: http://articles.techrepublic.com.com/5100-3513_11-6136763.html
The author refers to the minimum value of float as "approximately 1.5 times 10 to the 45th power", the resultant value (1.e+46) seems to disagree with the value given by the MinValue method.
Quite a good revision for math
--------------------------------------------------------------------------------------
Code for displaying min and max values and writing output to a text file
--------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace TestConsole2
{
class Program
{
static void Main(string[] args)
{
using (StreamWriter sw = new StreamWriter("Output.txt"))
{
sw.Write("This is the ");
sw.WriteLine("Float value types");
sw.WriteLine("-------------------");
sw.WriteLine("The maximum value of float is : " + float.MaxValue);
sw.WriteLine("The minimum value of float is : " + float.MinValue);
sw.Write("The date is: ");
sw.WriteLine(DateTime.Now);
}
}
}
}
Jon
|
|
|
|
|
jon_80 wrote: The author refers to the minimum value of float as "approximately 1.5 times 10 to the 45th power", the resultant value (1.e+46) seems to disagree with the value given by the MinValue method.
That's not the minimum value. He said it was the smallest, meaning that you can move the decimal to the LEFT 45 places, not right. Which, if you did this:
float x = 0.000000000000000000000000000000000000000000001F;
Console.WriteLine("Smallest : " + x);
results in Smallest : 1.401298E-45 , or approximately 1.5*10^(-45).
|
|
|
|
|
Yep that's right, cheers
Jon
|
|
|
|
|
|
jon_80 wrote:
2. Does anyone have a table with c# data types, description and range values, pls?
http://msdn2.microsoft.com/en-us/library/ya5y69ds(VS.80).aspx[^]
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
You mean it is in the documentation!!! Why on earth would anyone think to look there?
|
|
|
|
|
How to make generic list at runtime out of this example:
<br />
Assembly asm = Assembly.LoadFile(@"C:\MyDll.dll");<br />
Type myType = asm.GetType("WindowsApplication4.Class1");<br />
Now i dont know how to create generic List<t> from myType any idea?
With no reflection it would be like List<class1> lista = new List<class1>(), but how to make it with reflection?
Thanks.
-- modified at 9:51 Saturday 15th September, 2007
|
|
|
|
|
You just specify the type between the angle brackets:
List<myType> lista = new List<myType>();
Now you have a list of myType objects.
---
single minded; short sighted; long gone;
|
|
|
|
|
You can`t do that !
<br />
Error 1 The type or namespace name 'myType' could not be found (are you missing a using directive or an assembly reference?) D:\Documents and Settings\IvanM\My Documents\Visual Studio 2005\Projects\WindowsApplication4\WindowsApplication4\Form1.cs 24 18 WindowsApplication4<br />
|
|
|
|
|
He meant how to create List<mytype> during runtime
|
|
|
|
|
I see.
Why would anyone want to do that? Why not just using a List<object>?
Better yet, why not make an interface that the class can implement, so that you can create a list of that interface, and don't have to use reflection for anything that has to do with the objects.
---
single minded; short sighted; long gone;
|
|
|
|
|
You can do it like this:
<br />
Assembly asm = Assembly.LoadFile(@"C:\MyDll.dll");<br />
Type myType = asm.GetType("WindowsApplication4.Class1");<br />
<br />
Type ListType = typeof(List<>);<br />
Type ListOfMyType = ListType.MakeGenericType(myType);<br />
|
|
|
|
|
Thanks Giorgi,
only one question remains how to add objects to ListOfMyType? Thanks alot!
|
|
|
|
|
First you will need to create instance of ListOfMyType. You can do it like this:
<br />
object myObject = Activator.CreateInstance(ListOfMyType);<br />
Then use InvokeMember method of Type class to invoke any method of ListOfMyType class. Here is an example from MSDN: Type.InvokeMember Method[^]
|
|
|
|
|
I think that you can`t invoke Add member
Code:
<br />
myObject.GetType().InvokeMember("Add", BindingFlags.Public | BindingFlags.InvokeMethod, null, myObject, new object[] { myType1 } );<br />
Error:
<br />
Method 'System.Collections.Generic.List`1[[MojDll.Class1, MojDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Add' not found.<br />
|
|
|
|
|
I think it should look like this:
<br />
ListOfMyType.InvokeMember("Add", BindingFlags.Public | BindingFlags.InvokeMethod, null, myObject, new object[] { myType1 } );<br />
|
|
|
|
|
Ah didn`t created instance of class .... everything works now thanks !
|
|
|
|
|
You are welcome
|
|
|
|
|
//code is like this...
[XmlRoot("AutoupData")]
public class AutoupData
{
private ArrayList VersionArray;
public AutoupData()
{
VersionArray = new ArrayList();
}
[System.Xml.Serialization.XmlElement("versionInfo")]
public VersionC[] VersionInfos
{
get
{
VersionC[] VersionInfos = new VersionC[VersionArray.Count];
VersionArray.CopyTo(VersionInfos);
return VersionInfos;
}
set
{
if (value == null) return;
VersionC[] VersionInfos = (VersionC[])value;
VersionArray.Clear();
foreach (VersionC Versioninfo in VersionInfos)
VersionArray.Add(Versioninfo);
}
}
public int AddItem(VersionC VersionInfo)
{
return VersionArray.Add(VersionInfo);
}
}
public class VersionC
{
[XmlAttribute("version")]
public float version;
public VersionC()
{
}
public VersionC(float Version)
{
version = Version;
}
}
//code end...
is this using boxing and unboxing?
if it does then how can I convert this code to generic one?
I'm trying hard but the concept is so difficult to me.
please help me.
thanks.
|
|
|
|
|
arbrsoft wrote: is this using boxing and unboxing?
No. VersionC is a class . Only struct s cause boxing and unboxing.
arbrsoft wrote: if it does then how can I convert this code to generic one?
If you are using .NET 2.0 you should look at the Collection classes and then return a ReadOnlyCollection rather than copy arrays around. It might improve your design.
|
|
|
|
|
Hello everyone,
Can someone tell me little about streaming Media Files (Movie) over network using .Net Frame work?
I would like to make am Windows Application with can be used to receive and play movie files in the user application. Right now I am reading about DirectShow but I cannot find anything on sending and receiving media files (Audio/Video) over Network.
Any help to put me in the right direction will be great. Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
there is an ole field in the database , now i want that pic to show in the c# form.
How can i do it?
Soniagupta1@yahoo.co.in
|
|
|
|