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 / hmm maths

Author
Message
the nutty proffesor
19
Years of Service
User Offline
Joined: 4th Jun 2005
Location:
Posted: 16th Jun 2005 04:43
My darkbasic now for some reason refuses to multiply numbers. I have attached the mulitplication bit of the program it comes up with the error message unrecognised parameter. What is the world coming to?

If u cant beat the best give up and go home
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Jun 2005 04:55
why are you multiplying a string with a string?

Immunity and Annihalation makes Immunihalation...
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 16th Jun 2005 05:18
If you want to multiply decimal numbers then its '#' not '$'..'$' is for text.

encrypt$ = asciicode$ * keynumber$

would become

encrypt# = asciicode# * keynumber#

but if they are just integers then

encrypt = asciicode * keynumber

is fine !

the nutty proffesor
19
Years of Service
User Offline
Joined: 4th Jun 2005
Location:
Posted: 16th Jun 2005 07:08
but y can i add 2 strings together?

If u cant beat the best give up and go home
qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 16th Jun 2005 08:16 Edited at: 16th Jun 2005 08:17
you can add strings, you cannot multiply them

a$="hey"
b$=" bob"

a$+b$ would = "hey bob"... so it's not really "adding" in the way adding two integers is like

but how could you multiply strings? strings are characters

if you have a string that holds numbers, you can use int(a$) to get an integer from the string. theres one for floats also

on the other side str$(a) will turn a, an integer, into a string

Check out the DB Freebie Archive: http://lysergium.net/dbfree/ thanks to DARKGuy
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 16th Jun 2005 17:59
the nutty proffesor,

Yes, two strings can be multiplied together, easily, and I am not speaking of string concatenation. The master command, VAL(String$)! This turns the contents of the string into a value. If the String$ is a number, real or integer, that same value is returned. If it is text or any character besides a number, a value of 0 is returned.


+NanoBrain+
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Jun 2005 03:09
Here's what I think you want to do:

ecrypt$ = str$(val(asciicode#) * val(keynumber#))

Immunity and Annihalation makes Immunihalation...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Jun 2005 03:10
sorry i meant:


ecrypt$ = str$(val(asciicode$) * val(keynumber$))

Immunity and Annihalation makes Immunihalation...
the nutty proffesor
19
Years of Service
User Offline
Joined: 4th Jun 2005
Location:
Posted: 22nd Jun 2005 02:00 Edited at: 22nd Jun 2005 02:02
kk i sorta understand.
dus anyone no anything about using modular arithmatic in darkbasic I have the start of my code but it dose not work i have simplified it a bit so it dont take as long to read.

for some reason nothing happens can someone shed some light on this?

If u cant beat the best give up and go home
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd Jun 2005 05:07
everytime you begin the loop, you reset the variable a to 8.
set it BEFORE the loop, like this:



should work now

Immunity and Annihalation makes Immunihalation...
the nutty proffesor
19
Years of Service
User Offline
Joined: 4th Jun 2005
Location:
Posted: 22nd Jun 2005 07:12
ahh ok much better

If u cant beat the best give up and go home
the nutty proffesor
19
Years of Service
User Offline
Joined: 4th Jun 2005
Location:
Posted: 23rd Jun 2005 03:07
is there any way to raise a number to the power of another number
e.g. 5 to the power of 3 = 125
in darkbasic help there is something that is exp() but i have no idea how that works.

If u cant beat the best give up and go home
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 23rd Jun 2005 04:36 Edited at: 23rd Jun 2005 04:37
the nutty proffesor,

Use the ^ after the number set to be raised, and before the value of the amount to raise it. For example, 3^10.
a = 3^10 would make a to equal 59049.

As always, variables can be used in place of the exponent or the original value.




+NanoBrain+

Login to post a reply

Server time is: 2025-05-22 19:52:56
Your offset time is: 2025-05-22 19:52:56