Page 1 of 1 1
Topic Options
#74563 - 2003-04-16 08:28 PM Math Issue
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Why doesn't this:

FormatNumber(70/1000,2)

Yeild:

0.07

??????

No matter what I do, I keep getting 0

[ 16. April 2003, 20:28: Message edited by: jtokach ]
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#74564 - 2003-04-16 08:38 PM Re: Math Issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
because of math functioning in kix.

70 is integer and you must translate that.

if you want 0,07 all you need is:
code:
0.+70/1000

_________________________
!

download KiXnet

Top
#74565 - 2003-04-16 08:40 PM Re: Math Issue
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
J,
Don't know how your code can return
0.07
for me it returns
0.00
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#74566 - 2003-04-16 08:41 PM Re: Math Issue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Because you divide integer 70 by integer 1000 which yields integer 0. Thus, it all works correctly.
code:
FormatNumber(70.0/1000,2)
formatnumber(cdbl(70)/1000,2)

will give you 0.07 as result because you now divide double 7 by integer 1000. This is all explained in section 'Expressions' fo the KiXtart Manual.
_________________________
There are two types of vessels, submarines and targets.

Top
#74567 - 2003-04-16 08:44 PM Re: Math Issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hehee, me gets best golf score once again! [Big Grin]
_________________________
!

download KiXnet

Top
#74568 - 2003-04-16 08:46 PM Re: Math Issue
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Should I not be able to CDbl() this and get my value?

Disregard, saw the above after I wrote.

[ 16. April 2003, 20:49: Message edited by: jtokach ]
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#74569 - 2003-04-16 08:52 PM Re: Math Issue
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
formatnumber(cdbl(70)/1000,2) Causes Kixtart to stop. No error messages, it just stops.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#74570 - 2003-04-16 08:53 PM Re: Math Issue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
[Big Grin]
code:
70.0/1000

_________________________
There are two types of vessels, submarines and targets.

Top
#74571 - 2003-04-16 08:58 PM Re: Math Issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, I see that you can golf too.
congrats [Wink]
_________________________
!

download KiXnet

Top
#74572 - 2003-04-16 09:00 PM Re: Math Issue
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
That's cheating!

formatnumber(70*1.0,2) Works better as my value may not be <0

Anyhow, is this a bug with CDbl? I can't seem to use it any how any way???
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#74573 - 2003-04-16 09:03 PM Re: Math Issue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Again, read the Manual!

70*1.0 results in an integer (as expected/documented).
_________________________
There are two types of vessels, submarines and targets.

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 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.029 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