[TIB] Re: Integral Variables...


[Prev][Next][Index][Thread]

[TIB] Re: Integral Variables...



If you know your input will be integers, just use +, -, *, and ^, as the 
set of integers is closed under the addition, subtraction, 
multiplication, and exponential operators.  Then, instead of x/y use 
intDiv(x,y) and you should never deal with a decimal point.  However, 
this will not make a significant difference in memory/speed, which I had 
assumed was your initial point.

Tim Peterson wrote:
> (blinks)
> 
> Will exact(int(x)) seriously work?
> 
> I must test this.  Tomorrow, school, startTmr().  Or whatever that 
> function is.
> 
> Woo for the new features.  Is there a certain operation that I should 
> run to use the arithmatic functions for the ints?  Like 2+1=3, all 
> ints?  (Someone mentioned an intDiv() earlier...)
> 
> On Tue, 08 Apr 2003 22:03:25 -0500
>  "Tavis Segura" <tavis@hotmail.com> wrote:
> 
>> You can use exact(int(x)) to force x to become a pure integer. Don't 
>> add it everywhere, just in key places where you fear floating point 
>> numbers would sink in. If the floats come from the rand() function, 
>> put your multiplier inside the rand function... i.e. instead of using 
>> exact(int(6*rand())), use rand(6).. smaller, faster, and without 
>> intervening floats.
>>
>>> TI-89 question.  And, if it's relevant, I have AMS 2.08 up and 
>>> running on my
>>> calculator.
>>>
>>> I would like to force several of my variables into being 
>>> integers...under
>>> BASIC.  Why?  Because floating point calcs are nasty and long when 
>>> you're
>>> working purely with integers.  Does anyone know of a way to 
>>> accomplish this?
>>>
>>> Hopefully,
>>>    Eric
>>>
>>>
>>
>>
>> _________________________________________________________________
>> STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
>> http://join.msn.com/?page=features/junkmail
>>
>>
> 
> <TEXTAREA NAME="Signature" ROWS="4" COLS="60">
> 
> 
> 

-- 
Robert Mohr
mohr.42@osu.edu
mohrr@cis.ohio-state.edu




References: