|
Where can I find a list of variable types so I can type ("var mynum:float;") all my variables?
(comments are locked)
|
|
You generally don't need to do that; type inference takes care of it for you.
Pretty much the only way to get an untyped variable is to do this:
If you're declaring a variable with just the type and default value (" I was thinking mostly of class variables and I'd rather have them be null rather than come up with some default value.
Dec 18 '10 at 03:52 PM
davedev
(comments are locked)
|
|
The most common built in are:
Obviously there are more, but these are the basic ones everyone should be familiar with... Then there are a ton of types in the mono framework. I am not really a mono guy myself, I look things up in MSDN for .NET docs. Finally Unity expose several types that you find in the scripting reference, stuff like Vector3, Quaternion, MonoBehaviour, Time...
The types in C# and JS are 99% the same; the only differences I know of offhand are "bool" vs "boolean" and "string" vs "String".
Dec 17 '10 at 11:17 PM
Eric5h5
(comments are locked)
|
|
I found this page that lists types used in UScript I have a case where float type fails a comparison, so I was looking for single or double... seems double is the only one available. Yes, that's the same page I linked to in my answer. ;) Not sure what you mean by "double is the only one available", since you can see on that page that both single (AKA float) and double exist.
Apr 30 '11 at 09:06 AM
Eric5h5
I like float. The power to remain accurate at the nano level, while avoiding the overkill at Galactic sizes is indeed a plus. I am probably not as versed as you on the way floating point arithmetic is performed on the various processors with all the bit shifting and swapping tricks and the implicit conversions that are performed at the compile and hardware levels. My statement aims to keep in mind that a float even if considered a Single in some(perhaps most) contexts, it is not the same as a Single. Depending on the requirement of a particular calculation, a float may eat up more instructions cycles than a 'pure' Single/Double, in some cases twice as much. ...and I know, the general consensus on today's machines(above 486) is that float should be faster or at least equal(except for division perhaps), while Single generally outperforms Double but not always. But I still want to keep the difference in mind. At some point, I may run into the last level of optimization that will require to understand precisely how the numeric types are handled at the heart of the system to know what to use where. That of course is mainly required when an operation must be performed constantly(repeatedly) in a fast moving concurrent scenario. ...and you guessed it, I foresee that scenario is/(will be) in my project. Having said that, I admit I am on shifty ground based on mostly educated guessing.
Jun 24 '11 at 03:45 AM
dingben
float is an alias for System.Single. It's exactly the same.
Jun 24 '11 at 03:58 AM
Eric5h5
I dislike using float. I use decimals whenever precision is of paramount importance, and typecast to float only at the very last second if the value absolutely needs to be a float.
Jun 24 '11 at 04:03 AM
Dreamblur
Sorry... for my ambiguity. I am stuck in the pre-1990s where 'Single' refers to 'Single Precision FIXED point'...in those days a Single or a Double were fixed point... in today's meaning float implies Single Precision Float usually, double Float -> Double Precision Float. Thus where I used 'Single', I meant Single Precision FIXED point.
Jun 28 '11 at 08:35 AM
dingben
(comments are locked)
|
