datatypes

ActionScript – Default Datatype for Untyped Variables?

if i don't specifically type a variable in my code will it compile as a default datatype? for example, the "for each ... in" function works best without typing the variable: for each (var element in myArray) { //process each element } does my element variable have a datatype? if it is typed as Object is it...

Setprecision() for a float number in C++?

In C++, What are the random digits that are displayed after giving setprecision() for a floating point number? Note: After setting the fixed flag. example: float f1=3.14; cout < < fixed<<setprecision(10)<<f1<<endl; we get random numbers for the remaining 7 digits? But it is not the same case in double. ...

Datatypes and datatype modifiers in C

Hi I am pretty new to C. I recently came across this piece of code in C: #include <stdio.h> int main() { unsigned Abc = 1; signed Xyz = -1; if(Abc<Xyz) printf("Less"); else if(Abc>Xyz) printf("Great"); else if(Abc==Xyz) printf("Equal"); ...

C string literal storage between multiple copies of process or library

What is the behavior of various systems when you have more than one copy of a particular program or library running, do string literals get stored once in RAM or once for every copy of the process/library? What if they are stored in an array like: static const char *const foo[] = { "bar", "baz", "buz" }; Does the static change the beh...

MySQL timestamp to .NET timestamp

Hi all, I am using DBLinq to access a MySQL DB from C# .NET 3.5 I have created the dbml file for the Visual Studio 2010 ORM, and it loads fine - however when I compile the source I am met with errors regarding the conversion of MySQL timestamp to .NET DateTime. Now this kind of makes sense, because they are 2 'different' types (Though...

What type to use to store a single char in Scala?

I am writing a function which is meant to take a character as an argument and return a character. Using String for this looks a bit strange for me. Should I, or there is something like a char type in Scala 2.8? ...

How could we create "instances" of a type or record on the fly

This question is closely related to this one but i think is more general. Recently i try to create type "instances" on the fly with multimethods (or with a unique function constructor if possible), based in a metadata tag. I linked a type (a java class under the hood) with this tag and then i didnt know how to continue in a elegant way ...

Avoiding many inheriting classes

Lets say I have this class (just as an example): internal class Packet { private readonly UInt32 _length; private readonly Byte _type; private readonly UInt32 _requestId; } There are many different types of packets each of which inherit from this class and each packet type can have any number of properties of varying typ...

fetching float values from jformatted text field

I am able to create JFormatted TextField that accepts only float values,but I am not able to fetch that value.... I am declaring it .. stopAppFormattedTextField = new javax.swing.JFormattedTextField(new DecimalFormat("#.00")); and fetching the value using : double stop=(Double)stopAppFormattedTextField.getValue(); but the above sta...

storing negative number in decimal field of mysql table as of version 5.0.3

Hi, My table has few fields with an amount column of type decimal. This column will have either a deposited amount (a positive value) or a withdraw amount (a negative value). I store the positive value as just 120 and the negative value as -50. I sum the column and got the result as expected. Mysql version is: 5.1.33-community. When i ...

Storing .NET double value in Oracle DB

I'm using ODP.NET to access Oracle DB from C# .NET. Please see following code: OracleConnection con = new OracleConnection(); con.ConnectionString = "User Id=user;Password=pass;Data Source=localhost/orcl"; con.Open(); /* create table */ DbCommand command = con.CreateCommand(); command.CommandType = CommandType.Text; try ...

Convert MySQL tinyint types to bit

I used the MySQL Migration Toolkit to migrate a SQL Server 2008 database to MySQL. However, it converted all my bit types to tinyint. My data model doesn't like this, because I have a bunch of expressions testing for true/false, and not 0-255. Is there a way to tell the Toolkit to convert these different, or some SQL I can run on the ne...

What does the prefix L"..." stand for in GCC C without #including wchar?

That is, why does unsigned short var= L'ÿ' work, but unsigned short var[]= L"ÿ"; does not? ...

Data types (types of data I think?)

I have just started learning C# and would have one question that I cannot find answer on. Maybe I am just searching something slightly different. Also on MSDN I found following: C# is a strongly typed language; therefore every variable and object must have a declared type. Data Types Overview. I am also reading a book for it an...

Directory tree data type?

What would be the return type of the following method? (T) public T GetDirectoryContentsRecursively (string path) { ... } The method will read the contents of a remote directory, and read the contents of each sub-directory and each of that object's sub-directories and so on. I have thought about using List<object>, where object coul...

Generic Class & Type.GetType()

Hi All, Bit of a puzzler, I have a generic class public abstract class MyClass<T> : UserControl { } and I have got a type like this Type type = Type.GetType("Type From DB as String", true, true); and I want to create and instance of MyClass using the type... But this doesn't work. MyClass<type> control = (MyClass<type>)LoadCon...

typedef problem

hey people kindly tell me if the following declaration is correct? if it is then kindly explain typedef char HELLO[5]; HELLO name; now what datatype is name? [as in a character,integer etc] i came to know that name will be an array of strings but when i run the following programme i get error #include<stdio.h> typedef char HEL...

Problem while scanning a char and float simultaneously.

I am trying to take five character and 5 float input. main() { char c[5]; float q[5]; int i; for(i=0;i<5;i++) { printf("\n%d ",i); scanf("%c",c+i); scanf("%f",q+i); } } But the output is absurd. After two sequential scans, it skips third scan and then again skips fifth scan. I am not ab...

Which is the first integer that an IEEE 754 float is incapable of representing exactly?

For clarity, if I'm using a language that implements IEE 754 floats and I declare: float f0 = 0.f; float f1 = 1.f; ...and then print them back out, I'll get 0.0000 and 1.0000 - exactly. But IEE 754 isn't capable of representing all the numbers along the real line. Close to zero, the 'gaps' are small; as you get further away, the gaps...

C++: Store large numbers in a float like PHP?

In PHP if you go above INT_MAX it will cast it as a float, allowing very high numbers to be formed (that are non-decimal as well), is this possible to do in C++ or are the way they store floating point/double precision numbers different? The reason why is I am wishing to benchmark large factorials, but something such as 80! is way too l...