Jump to content

Recommended Posts

Posted

So for whatever reason I've been using the int variable type for my scripts. I have 0 clue why I use it, no idea what it is exactly, or where it actually comes from. Does anyone have any idea???

Posted (edited)

int is equal to short. Int is used in C and if you type int instead of short, you should get an error I guess in CS. I bet you have been reading Idles C scripts, mixing them up :wink:

 

The size of the integer can variate depending on what you will use it for and I never use a bigger one that I will need but not the short in Oblivion as it is 16-bit and the limit it can hold is 2^15-1 (32767) or [/size]-2^15 (-32768)[/size]. If we want to use a bigger variable, then we must use the Long variable type

 

There is an exception: OBSE

 

NOTE : Long ago, an OBSE developer mentioned that, internally, the engine stores ALL vars as floats. (QQuix) so it is no problem if you set short value above 32767, the maximum limit positive number is 2,147,483,647 (or hexadecimal 7FFF,FFFF16)

Edited by Pellape
Posted (edited)

I should clarify, I know what an int is in general, and I'm used to it being an unsigned long (like in C++)

 

My problem is that I have 0 clue what it means for Oblivion. In Oblivion all numbers are stored as floats, and the only other number types are signed short and longs

int test

Begin OnActivate
  let test := 9.9
  PrintC "number %g", test
End

This is completely valid in Oblivion, but what is this type actually? I can't find any information on its range. This type does truncate floats properly, but that's all I can conclusively state along with ints being signed still

 

The CS wiki only mentions shorts and longs, and the OBSE docs doesn't describe it at all (but still describes certain function parameters and results as being of the type int)

Edited by KatsAwful
Posted (edited)

Why so many sorts of types? Good question but is about optimating the code as much as possible I guess. In a PC it doesn't matter but lets see if we use the code in a tiny machine or in an old computer with low RAM, then it matters. The smallest type I ever used is bol, bolean which I suspect is a 2-bit type. In Visual Basic there is no need to declare any variables as if you do not, it will become a common 32-bit type, that can hold any form of value, from strings, integers, floats or whatever. That is cheating but that is basic and we do not need to declare variables in basic ever if we do not want too.

 

Good point as I do not have a clue as I first thought you mixed C up with Oblivion.... ;)

Edited by Pellape
Posted

Thanks for bringing this up.

 

I recently started to use INTs either, but rather for bools.

Where I merely just use tiny amounts (like 0 or 1). :)

 

I would be interested in a clarification about this type either. ^^

Posted

Cool. It do explain some and I think it is good as then it also means that the FPU will do the calculations and trunc any crap out as 1+1 might be 2.000001... The CPU are needed for other stuff anyway.

 

My first 386, did not have a FPU, so if I did not think while typing C on it, and used float, it would CRASH. I had to use the Atari if I wanted to use floats... ;) It was possible to buy a separate FPU though, if I wanted one.

 

JustChill?? Where do you use bools? In Oblivion or with C?

Posted

I use int (now we know it's just a short), as bools (where I use 0 as equivalent for "false" and 1 as equivalent for "true") :wink:

Initially I thought INT is even smaller than short, but well... learning never stops. ^^

Posted

Since numbers are stored as floats its doesn't matter if you use shorts/int or longs at the end of the day. I just use int for everything cause it conceptually lines up with what i use that kind of type for

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...