Jump to content

Round up to nearest 5


Recommended Posts

If you are scripting I think you have to use Trunc(). (I'm pretty sure it will work on Integer and Long Integer types as well as Real. Or at least I hope it will.)

INT isn't a vector script function.

I thought there used to be DIV and MOD script functions, but I can't find them in the function reference.

hth

mk

Link to comment

I was just doing a whole heap of distance calculations and had never used LONGINTs before now. Used them when I realised that it was levelling out on higher number sets.

Is there a low limitation to using LONGINTs more often? What are the advantages/disadvantages? Presumable they are slightly larger data wise which may cause an accumulative slow down in loops... But what else do they do?

J

Link to comment

Integers (short int) have a value range of -32,768 to 32,767 = 16 bits = 2 bytes

whereas,

Longint (long int) have a range of -2,147,483,648 to 2,147,483,647 = 32 bits = 4 bytes.

For most purposes a short integer will be adequate but if the result of an operation is also a short and the value falls outside the limits of the integer, the result will be truncated to the lower/upper limits.

This is why Trunc is declared as a LongInt. If the real value is 100,000.736 and it is assigned to a short Integer, the value will be truncated to 32,767 but if it is assigned to a LongInt then it will be 100,000 as expected.

Moreover, rgb colors have a range of 0 to 65,535 and are declared as LongInt to hold the upper values but in reality it is an unsigned short integer meaning it does not have negative values.

As for DIV and MOD, they are still part of VS but they are operands for integer Division and Remainder.

Link to comment
  • 9 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...