Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Decimal Numbers
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
T-Master




Joined: 10 Dec 2003
Posts: 74

PostPosted: Thu Aug 19, 2004 3:57 pm    Post subject: Decimal Numbers Reply with quote

Has the compiler always rejected decimal numbers, ie:

3.4 * i
1.5 * i
i / 6.5

This is really frustrating and completely undesired functionality, :/
Back to top
View user's profile Send private message
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Thu Aug 19, 2004 4:07 pm    Post subject: Reply with quote

It's always done that. Hamsterspeak can only process integers.
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
T-Master




Joined: 10 Dec 2003
Posts: 74

PostPosted: Thu Aug 19, 2004 4:16 pm    Post subject: Reply with quote

I think it's probably because Hamsterspeak assumes anything with a period is a string/variable/constant/whatever and not a number, because QBASIC will allow you to pass a = a * 1.5.
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Aug 19, 2004 5:27 pm    Post subject: Reply with quote

Periods are not reserved for anything. You can name variables, scripts, etc. with periods in their names.

So when HSpeak sees a period in the middle of a number, its like seeing '1A2', which it can't understand.

But of course there are no fixed or floating point numbers.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Thu Aug 19, 2004 6:13 pm    Post subject: Reply with quote

I wonder if you could make a variable named 1.5.

Anyway, yeah. I always multiply my numbers. For example, the hero's x/y velocity in SG3 is stored at ten times its value in pixels.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
T-Master




Joined: 10 Dec 2003
Posts: 74

PostPosted: Thu Aug 19, 2004 6:47 pm    Post subject: Reply with quote

It's odd that it's never come up in my scripts before my most recent project. On that note, it'd be funny to have your script read something like:

1.5 := 1
Back to top
View user's profile Send private message
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Thu Aug 19, 2004 9:49 pm    Post subject: Reply with quote

I think Hamsterspeak uses a different language from the rest of the OHR, TM.
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Aug 19, 2004 10:17 pm    Post subject: Reply with quote

Me wrote:
I think Hamsterspeak uses a different language from the rest of the OHR, TM.


HamsterSpeak is the language of the OHR. What do you mean?


I just tried it out now, and I'm surprised that HamsterSpeak allows labels to start with a numeral. The language is excessively open.

So, yes,
Code:
variable(1.5)
1.5:=99
showvalue(1.5)

displays 99.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Fri Aug 20, 2004 12:59 am    Post subject: Reply with quote

I mean Hamsterspeak != coded in QBASIC.
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Aug 20, 2004 3:00 am    Post subject: Reply with quote

HSpeak version 2 uses Euphoria, which of course has floating point numbers. What its coded in doesn't actually make any difference, it's James' coding that doesn't read them.

In fact, HSpeak version 1 was coded in QuickBasic, and did virtually the same job of compiling.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Guest







PostPosted: Fri Aug 20, 2004 10:41 am    Post subject: Reply with quote

Just wanted to emphasize Moogle1's point (at least I think it was his point) that you can usually get away without decimals. Storing variables with factors of ten multiplied in is a good way. Using fractions is another. For instance, your variable*1.5 example would work just as well as variable*3/2. It'll cut off the decimal place, but it'll give you essentially what you want.
Back to top
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Aug 20, 2004 6:24 pm    Post subject: Reply with quote

You mean, 3/2 works and 1.5 doesn't.

I would just like to point out that

var * 3 / 2

is not the same as

3 / 2 * var
or
(3 / 2) * var

3 / 2 works out to 1. I suggest you use paranthesis to save worrying:
Code:
 (var * 3) / 2

_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Fri Aug 20, 2004 8:13 pm    Post subject: Reply with quote

Order of ops makes x*3/2 == (x*3)/2.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Aug 20, 2004 9:29 pm    Post subject: Reply with quote

Yes, but the paranthesis insures that you don't get it in the wrong order.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
T-Master




Joined: 10 Dec 2003
Posts: 74

PostPosted: Mon Aug 23, 2004 6:21 pm    Post subject: Reply with quote

"I would just like to point out that var * 3 / 2
is not the same as 3 / 2 * var"

Yes it is.

var = 6

6 * 3 / 2 = 9
3 / 2 * 6 = 9
3 * 6 / 2 = 9

var * 3 / 2 == 3 * var / 2 == 3 / 2 * var

Order of ops doesn't matter when you're only dealing with multiplication and division.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group