| 
| 
| 
| #133704 - 2005-02-12 10:24 PM  Integers vs. Long Integers |  
| Allen   KiX Supporter
 
       
 Registered:  2003-04-19
 Posts: 4562
 Loc:  USA
 | 
I hate asking stupid questions, but for the life of me I cannot find an explaination that is in terms I can make any since of.  What is the difference between Integers and Long Integers.  I've googled and found the 64bit/32bit explainations... sorry, that doesn't help.  I thought an integer was a whole number, but obviously there is something more to it than that.  I wrote a little test script just to see what would happen:
 Code:
 
  break on
 
 for $i=1 to 20
 ? "" + $i + ":" + vartype($i)
 sleep 1
 next
 
 
 
 In this example, every number is a vartype of 3 (Long Integer).  So my second question is, where in kixtart would you find a Integer (not Long Integer)?
 |  
| Top |  |  |  |  
| 
| 
| #133707 - 2005-02-12 11:42 PM  Re: Integers vs. Long Integers |  
| Sealeopard   KiX Master
 
       
   Registered:  2001-04-25
 Posts: 11165
 Loc:  Boston, MA, USA
 | 
I guess it would be appropriate to refer to the KiXtart Manual:
 Quote:
 
 Variable types
 In KiXtart, variables are always of one fundamental data type: Variant. The current implementation of KiXtart uses three types of variants: long integers, doubles (8-byte floating point numbers) and strings. A variant of type string can contain up to 32,000 characters. Integer variables can contain any value between -2,147,483,648 and 2,147,483,647. The type of a variable is automatically changed to the result of the expression that is assigned to it. This means that if you assign a string to a variable containing an integer, the type of the variable is changed to a string.
 
 
 
 
 
 I don't think you'd see an Integer, the number might just be available due to the API Ruud is using to get the variable type.
 
_________________________There are two types of vessels, submarines and targets.
 |  
| Top |  |  |  |  
| 
| 
| #133710 - 2005-02-13 12:32 AM  Re: Integers vs. Long Integers |  
| Allen   KiX Supporter
 
       
 Registered:  2003-04-19
 Posts: 4562
 Loc:  USA
 | 
 Quote:
 
 KiXtart uses three types of variants: long integers, doubles (8-byte floating point numbers) and strings
 
 
 
 
 
 Thanks Jens... that looks like that answers the question right there.  Since I rarely write any code other than kixtart, I guess I don't have to worry about the other types of integers.
 |  
| Top |  |  |  |  
| 
| 
| #133711 - 2005-02-13 12:41 AM  Re: Integers vs. Long Integers |  
| Howard Bullock   KiX Supporter
 
       
   Registered:  2000-09-15
 Posts: 5809
 Loc:  Harrisburg, PA USA
 | 
It is questions like this that seem to hold us dedicated KiXtart user's attention. Shawn where is your conversation with Ruud? Topics like this would be great conversation.  
 |  
| Top |  |  |  |  
| 
| 
| #133714 - 2005-02-14 10:12 AM  Re: Integers vs. Long Integers |  
| Richard H.   Administrator
 
       
 Registered:  2000-01-24
 Posts: 4946
 Loc:  Leatherhead, Surrey, UK
 | 
KiXtart is not strongly typed, so the issue of integer size other than the maximum supported is only of minor interest. Your data and variables will be silently converted by context, which makes setting a type pretty pointless.
 For example (ignoring signing for the present), say you have a variable "i" declared as a one byte integer.
 
 In "C":
 Code:
 
 i=255+1 
 "i" now contains zero, as the expression has reached the size of the variable and the extra bits are dropped.
 
 In KiXtart:
 Code:
 
 $i=255+1 
 "$i" now has the value 256. Even worse, it has been converted to a 2 or 4 byte integer so that it is large enough to store the result.
 
 As another example, take a biwise NOT (not to be confused with KiXtarts logical NOT). A bitwise NOT simply reverses all the bits in an expression. Very useful for switching individual bits on and off amongst other things.
 
 The problem is that without being able to assign a size to the expression, you can't determine the size of the result.
 
 Should "NOT 0" be 255, 65535 or 4294967295?
 
 Actually, that last one is even trickier as KiXtart does not support unsigned integers so &FFFFFFFF is "-1", which is a major pain.
 
 The same problem occurs when you want to do a bitwise shift or roll - unless you can fix the size of the expression you are going to have problems, or you are going to have to code around it by explicitly passing the expression size as well as the expression.
 
 There was a recent query on the board about converting a hash key generation algorithm to KiXtart.  It is possible, but damned hard in part because of the lack of strongly typed data types.
 
 I particularly miss being able to use unsigned types when it comes to network scripting - it's a bit of a coding nightmare when the values suddenly become negative.
 
 Generally you can code around the problems, but it does make life difficult when trying to convert code from other languages where the (fixed) data size is a part of the coding technique.
 |  
| Top |  |  |  |  
 Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
 
 | 
| 
 
| 0 registered
and 550 anonymous users online. 
 | 
 |  |