Page 1 of 1 1
Topic Options
#75065 - 2003-05-20 06:55 PM I am missing something here...
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I know this has been asked a million and one times.

But, here goes:

code:
cls
break on
?@kix
DIM $tst,$tst2,$tst3
$tst=val(1)
$tst2=val(3)
$tst3=$tst/$tst2
?$tst3
get $

I need to see .333.. I have also tried using CLNG, LONG, etc.

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75066 - 2003-05-20 06:56 PM Re: I am missing something here...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
$tst=cdbl(1)
$tst2=cdbl(3)
$tst3=$tst/$tst2
?$tst3



[ 20. May 2003, 19:00: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#75067 - 2003-05-20 07:02 PM Re: I am missing something here...
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Sheesh..

Thanks!

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75068 - 2003-05-20 07:56 PM Re: I am missing something here...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
tst=1
$tst2=3
$tst3=0.+$tst/$tst2
? $tst3
_________________________
!

download KiXnet

Top
#75069 - 2003-05-20 08:05 PM Re: I am missing something here...
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Jooel,

Comes out as 0.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75070 - 2003-05-20 08:07 PM Re: I am missing something here...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Which is actually the correct result as th division is calculated before the adding, thus the division still results in an integer.
_________________________
There are two types of vessels, submarines and targets.

Top
#75071 - 2003-05-20 08:10 PM Re: I am missing something here...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn math! [Big Grin]
_________________________
!

download KiXnet

Top
#75072 - 2003-05-20 08:26 PM Re: I am missing something here...
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
$tst3=(0.+$tst)/$tst2
Top
#75073 - 2003-05-20 09:10 PM Re: I am missing something here...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wonder...
bryce, are you wiseguy or something [Razz]
_________________________
!

download KiXnet

Top
#75074 - 2003-05-20 09:14 PM Re: I am missing something here...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Hmmm. Operator precendence stikes again.
Top
#75075 - 2003-05-20 11:12 PM Re: I am missing something here...
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Well..

Here it is..

Playing around this afternoon we see:
code:
$tst=1
$tst2=3
$tst3=(0.+$tst)/$tst2
? $tst3
$tst3=cdbl($tst3)*100
? $tst3
$tst3=split($tst3,'.')[0]+'.'+left(split($tst3,'.')[1],2)
? $tst3
get $

And, we could expand on this:
code:
 CLS
BREAK ON
COLOR g+/n
$script='pu.kix'
?'Press anykey to start test (open '+$script+', READ & display lines, CLOSE..'
GET $x
$result=1
IF exist('@scriptdir\'+$script)
$result=open(1,'@scriptdir\'+$script)
ELSE
BEEP
? "Sorry, pu.kix appears to be missing."
SLEEP 3
EXIT
ENDIF

$maxi=1
$i=1
IF $result = 0
$maxline = readline(1)
WHILE @error = 0
$maxline
$maxline = readline(1)
$maxi=$maxi+1
LOOP
$result=close(1)
$maxi=cdbl($maxi-1)
ENDIF

$i=cdbl($i)
$result = open(1,'@scriptdir\'+$script)
IF $result = 0
$line = readline(1)
WHILE @error = 0
$pct=cdbl(($i/$maxi)*100)
IF len(split($pct,'.')[1])>2
$pct=LEFT($pct,5)
ENDIF
COLOR w/n
?'Line '+$i+'/'+$maxi+' read of '+$pct+'% done: ['
COLOR w+/n
$line
COLOR w/n
']'
$line=readline(1)
$i=$i+1
LOOP
$result=close(1)
ELSE
BEEP
?'Sorry, failed to open '+$script+', errorcode : ['+@error+']'
ENDIF
GET $

Cheers!

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.062 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org