Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / exponent iation

Author
Message
SEN01
19
Years of Service
User Offline
Joined: 22nd Feb 2006
Location:
Posted: 22nd Feb 2006 13:43
In many BASIC dialects: PRINT 5^(1/2) returns the value 2.236068

In DarkBASIC Classic: PRINT 5^(1/2) returns the value 0.

If floating point variables are declared in DarkBASIC:

a#=1:b#=2
PRINT 5^(a#/b#)

DarkBASIC prints the message \"unrecognised parameter at line 2\"

How can DarkBASIC Classic be pursuaded to give the correct answer to:

5^(1/2)
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd Feb 2006 14:59 Edited at: 22nd Feb 2006 15:03
print 5^(1.0/2) works just fine.
1/2 doesn't go because the answer will be rounded down when using only integer values (1/2 = 0 for DB, 1.0/2 = 0.5) which means that 5^(1/2) should give 1 (5^0 = 1) and not 0 (Which it does).

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
SEN01
19
Years of Service
User Offline
Joined: 22nd Feb 2006
Location:
Posted: 23rd Feb 2006 02:59
Yes - DarkBASIC returns a value of 1 when asked to print 5^(1/2)
sorry for the mistake. QBASIC returns a value of 2.236068 when asked to print 5^(1/2).

In DarkBASIC PRINT 5^(1.0/2) was tried, as suggested above, but DarkBASIC gave an error report, saying;

"Unrecognised parameter at line 1"

We have DarkBASIC version 1.08(B)
Why does PRINT 5^(1.0/2) cause an error?
SEN01
19
Years of Service
User Offline
Joined: 22nd Feb 2006
Location:
Posted: 22nd May 2006 10:59
Using DarkBASIC Classic we can hide the mouse cursor using "HIDE MOUSE" - is it possible to disable the mouse altogether?

Login to post a reply

Server time is: 2025-05-23 18:48:47
Your offset time is: 2025-05-23 18:48:47