View previous topic :: View next topic |
Author |
Message |
T-Master
Joined: 10 Dec 2003 Posts: 74
|
Posted: Thu Aug 19, 2004 3:57 pm Post subject: Decimal Numbers |
|
|
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 |
|
 |
Me HI.

Joined: 30 Mar 2003 Posts: 870 Location: MY CUSTOM TITLE CAME BACK
|
Posted: Thu Aug 19, 2004 4:07 pm Post subject: |
|
|
It's always done that. Hamsterspeak can only process integers. _________________ UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START |
|
Back to top |
|
 |
T-Master
Joined: 10 Dec 2003 Posts: 74
|
Posted: Thu Aug 19, 2004 4:16 pm Post subject: |
|
|
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 |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Aug 19, 2004 5:27 pm Post subject: |
|
|
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 |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Thu Aug 19, 2004 6:13 pm Post subject: |
|
|
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 |
|
 |
T-Master
Joined: 10 Dec 2003 Posts: 74
|
Posted: Thu Aug 19, 2004 6:47 pm Post subject: |
|
|
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 |
|
 |
Me HI.

Joined: 30 Mar 2003 Posts: 870 Location: MY CUSTOM TITLE CAME BACK
|
Posted: Thu Aug 19, 2004 9:49 pm Post subject: |
|
|
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 |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Aug 19, 2004 10:17 pm Post subject: |
|
|
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 |
|
 |
Me HI.

Joined: 30 Mar 2003 Posts: 870 Location: MY CUSTOM TITLE CAME BACK
|
Posted: Fri Aug 20, 2004 12:59 am Post subject: |
|
|
I mean Hamsterspeak != coded in QBASIC. _________________ UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Aug 20, 2004 3:00 am Post subject: |
|
|
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 |
|
 |
Guest
|
Posted: Fri Aug 20, 2004 10:41 am Post subject: |
|
|
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
|
Posted: Fri Aug 20, 2004 6:24 pm Post subject: |
|
|
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:
_________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Fri Aug 20, 2004 8:13 pm Post subject: |
|
|
Order of ops makes x*3/2 == (x*3)/2. _________________
|
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Aug 20, 2004 9:29 pm Post subject: |
|
|
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 |
|
 |
T-Master
Joined: 10 Dec 2003 Posts: 74
|
Posted: Mon Aug 23, 2004 6:21 pm Post subject: |
|
|
"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 |
|
 |
|