Declaring SPECIFIC Variables?
7 posts • Page 1 of 1
Declaring SPECIFIC Variables?
I thought that this question were never asked, so....
Hey, I was wondering on how to declare specific variables for this problem:
I do not want to waste 32 bits, which is the capacity of int, ranging from -2147483648 to 2147483647, for holding (for instance) gear variable from 1 to 6 (can be sufficiently stored in byte, which has 8 bits, ranging from -127 to 128). Furthermore, I can also use unsigned byte, which has equal capacity of byte (8 bits), ranging from 0 to 255.
Yes, we can declare integer, but we cannot declare byte, short, int, and (possibly) long separately.
Yes, we can declare decimals, but we cannot declare float and double separately.
Can we declare these specific variables I've stated above? If yes, how?
Is it even possible to use unsigned and signed variable? If yes, how?
Hey, I was wondering on how to declare specific variables for this problem:
I do not want to waste 32 bits, which is the capacity of int, ranging from -2147483648 to 2147483647, for holding (for instance) gear variable from 1 to 6 (can be sufficiently stored in byte, which has 8 bits, ranging from -127 to 128). Furthermore, I can also use unsigned byte, which has equal capacity of byte (8 bits), ranging from 0 to 255.
Yes, we can declare integer, but we cannot declare byte, short, int, and (possibly) long separately.
Yes, we can declare decimals, but we cannot declare float and double separately.
Can we declare these specific variables I've stated above? If yes, how?
Is it even possible to use unsigned and signed variable? If yes, how?
When your computer has multiple cores but uses programs that only supports single core....

That's Algodoo!

That's Algodoo!
-

Anbang11 - Posts: 72
- Joined: Sat May 09, 2015 7:46 am
- Location: Earth.
Re: Declaring SPECIFIC Variables?
Why you want it? There is no need for that. Thyme is just script language.
There are following auto-assigned-types:
integer {a := 1}
float {a := 1.0}
boolean {a := true}
string {a := "1"}
procedure {a := {1+1}}
function {a := (x) => {1+x}}
list {a := [1,"1", true, {1}]}
object {a := scene.addBox({pos := [0,0]})}
In some cases automatic type conversion works ("a" + 1) will give string "a1" in result
There are following auto-assigned-types:
integer {a := 1}
float {a := 1.0}
boolean {a := true}
string {a := "1"}
procedure {a := {1+1}}
function {a := (x) => {1+x}}
list {a := [1,"1", true, {1}]}
object {a := scene.addBox({pos := [0,0]})}
In some cases automatic type conversion works ("a" + 1) will give string "a1" in result
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Declaring SPECIFIC Variables?
Don't you see my problem I've wrote on the original post? What a pity having 2 billion numbers left unused just for holding small number.
When your computer has multiple cores but uses programs that only supports single core....

That's Algodoo!

That's Algodoo!
-

Anbang11 - Posts: 72
- Joined: Sat May 09, 2015 7:46 am
- Location: Earth.
Re: Declaring SPECIFIC Variables?
Anbang11 wrote:Don't you see my problem I've wrote on the original post? What a pity having 2 billion numbers left unused just for holding small number.
That economy makes sense on large scale. For typical algodoo script data few megabytes is max of what you really need. So why bothering?
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Declaring SPECIFIC Variables?
There isn't a way to declaring specific variables? That's okay.
When your computer has multiple cores but uses programs that only supports single core....

That's Algodoo!

That's Algodoo!
-

Anbang11 - Posts: 72
- Joined: Sat May 09, 2015 7:46 am
- Location: Earth.
Re: Declaring SPECIFIC Variables?
Anbang11 wrote:There isn't a way to declaring specific variables? That's okay.
No, it's automatic from value.
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Declaring SPECIFIC Variables?
You dont really waste "2 billion numbers", you just "waste" a few mere byte, about 30. That may seem like a lot, but now imagine this:
30 bytes...
...of about 1028^3 bytes...
Quiiite a minority.
30 bytes...
...of about 1028^3 bytes...
Quiiite a minority.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
7 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 9 guests



