datatypes

What does "unsigned" in MySQL mean and when to use it?

What does "unsigned" mean in MySQL and when should I use it? ...

How to display the maximum value of a unsigned long long in C?

What am I doing wrong here? $ cat size.c #include<stdio.h> #include<math.h> int main() { printf ("sizeof unsigned int = %d bytes.\n", sizeof(unsigned int)); printf ("sizeof unsigned long long = %d bytes.\n", sizeof(unsigned long long)); printf ("max unsigned int = %d\n", (int)(pow(2, 32) - 1)); printf ("max unsigned long long = %lld\...

Determining type of variable during run-time in C

I have several variables of type char (array), int, and double. Is there a way to identify what type they are during run-time? For example, I'm looking for something like: int dummyInt = 5; double dummyDouble = 5.0; dummyInt == int ? printf("yes, it's of int type\n") : printf("no, it's not of int type\n"); dummyDouble ...

General Array/Pointer Data Type

I'm coding a C++ function that accepts a string, an array and the size of the array. It looks like this: bool funcname (string skey, string sArr[], int arrSz) I want to pass several array data types, such as double, char, long int, etc. Is it right to use string as data type for the array? Or is there a general data type that I can us...

Generally, are string (or varchar) fields used as join fields?

We have two tables. The first contains a name (varchar) field. The second contains a field that references the name field from the first table. This foreign key in the second table will be repeated for every row associated with that name. Is it generally discouraged to use a varchar/string field as a join between two tables? When is t...

Converting C# Data Types from unknown sources

There seems to be a lot of confusion around converting strings (usually) to their appropriate datatype, whilst validating it on the fly as well. Wherever I look - blogs, articles, code samples, forums.. a few people seem to have a preferred way of dealing with these scenarios. The case is usually a string/object that comes from an unkn...

OCaml: Is there a function with type 'a -> 'a other than the identity function?

This isn't a homework question, by the way. It got brought up in class but my teacher couldn't think of any. Thanks. ...

How should I use UUID with JavaDB/Derby and JDBC?

I currently use INT as type for primary key in JavaDB (Apache Derby), but since I'm implementing an distributed system I would like to change the type to java.util.UUID. A few questions about this: What datatype in JavaDB/Derby should I use for UUID? I have seen CHAR(16) FOR BIT DATA been mentioned but I don't know much about it. Is VA...

Searching Color Similarity

I'm working on a project that involves scanning in colors to RGB then searching through a database of more RGB data to see what is most similar to the scanned in color. I've decided that the easiest way to determine what "similar" means in this case is to represent the colors in three dimensional space and then find the distance between ...

Priority Queue with a find function - Fastest Implementation

Hi, I am looking at implementing a priority queue with an added requirement, a find/search function which will tell whether an item is anywhere within the queue. So the functions will be: insert, del-min and find. I am unsure whether I should use a Heap or a Self-balancing binary search tree. It appears PQs are usually implemented wit...

fgetc does not identify EOF

Below program runs fine on solaris/linux various flavor, but not on AIX. on AIX while(c!=EOF) if i replace by while(c!=0xff) it just run fine completely Any thought ? i checked the man page of fgetc on aix, and it should return EOF constant ! #include <stdio.h> #include<unistd.h> #include <string.h> int main() { char c; FI...

Managing user-defined types across various modules

What is the best way to manage common user-defined types across VBA modules? I use the same user-defined types in different modules. For example, I often need to represent (x,y) points, so I end up having this Type in different modules: Type XYpointType x As Double y As Double End Type I pass arguments of type XYpointType to...

PHP: MySql Data Type for monetary values.

What is the best way to store monetary values in MySql. I've seen this: decimal(5,2) but then you can't enter in more than $999.99 for the amount. I mean I know you can change the 5 to something else but this doesn't seem like the most appropriate way to do this.. then again I'm not sure that's why I'm posting. I've also seen storing ...

Actionscript equivalent of Python's class "set"

In Python, there is a class called "set". I realize that similar functionality could be implemented in AS by a Dictionary where only the keys matter. But it seems that this should be a built-in type for ActionScript. Unfortunately, it's nearly impossible to search for. Before I go off and code up my own "set" class, does it already exis...

Choosing a schema for SQL lookup table in the context of LINQ to SQL: sql_variant or multiple fields

I have a question similar to this but in the context of L2S. I want to create a lookup table to store values that could be one of several possible datatypes. As suggested in the referenced question, I could use sql_variant datatype. However, L2S maps sql_variant to Object, which is suboptimal. I'm guessing it's possible to get at the tab...

Unexpected error about DateTime type

Hi everyone, I have a .aspx page for adding new product include the following field: ID, Name, DateTime, Price and it run well at localhost but when I publish it and up to the server, then I get the following error: System.Data.UpdateException: An error occurred while updating the entries. See the InnerException for details. ---> Sy...

How to determine type from a given string input.

Is there any method to detect the type from a given string input? Eg: string s = "07/12/1999"; I need a method like string DetectType( s ) { .... } which would return me the matched datatype. i.e. "DateTime" in this case. Would I have to write this from scratch? Just wanted to check if anybody knows of a better way before I went abo...

Is there a Haskell equivalent of OOP's abstract classes, using algebraic data types or polymorphism?

In Haskell, is it possible to write a function with a signature that can accept two different (although similar) data types, and operate differently depending on what type is passed in? An example might make my question clearer. If I have a function named myFunction, and two types named MyTypeA and MyTypeB, can I define myFunction so th...

Interval datatype in MySql

Does MySql has the Interval datatype as PostgreSQL (or like TimeSpan in .net) does? ...

How does PHP know what type of variables it uses (or does it)?

I haven't done much programing in many languages, but I know in C(++), you have to declare a variable type (int,char,etc). In PHP you, of course, don't have to do that. You can start with $str = "something"; then later $str = array("something" => "smells"); and she is happy. How does PHP compile? How does it know what the variable typ...