If you had any idea how that is total nonsense, you'd know why you should shut up.zac352 wrote:If you had any idea how base 2 is stored in the memory, you'd know why that happens.
math.floor()
Re: math.floor()
Re: math.floor()
You don't know what you're talking about...giniu wrote:it's just how floor and ceil are defined mathematically and not related to how it is stored - it's like saying that sky is blue because of rgb representation in computer, really. Just stick to definition from any (elementary I guess) school math book you might have avoided in past - or wikipedia page linked in third post.zac352 wrote:If you had any idea how base 2 is stored in the memory, you'd know why that happens.
char starts at 00000000, and ends at 11111111.
unsigned char starts at 00000000, and ends at 11111111.
char starts at -128, and ends at 127.
unsigned char starts at 0, and ends at 255.
The first byte is used as the negative sign, and is just subtracted.
Add 2^num_bits/2 to your number to see its unsigned equivalent.
Lua, I believe, has 4 bytes allocated to whole number storage. Not comlpetely sure.
Floor cuts the decimal point numbers off the base 2 end.
You all need to stop acting like base 2 doesn't exist...
Hello, I am not dead.
Re: math.floor()
I'll let you respond to that yourself:zac352 wrote:Add 2^num_bits/2 to your number to see its unsigned equivalent.
Lua, I believe, has 4 bytes allocated to whole number storage. Not comlpetely sure.
Floor cuts the decimal point numbers off the base 2 end.
With your ignorance you simply can't afford that arrogance.zac352 wrote:You don't know what you're talking about...
Re: math.floor()
I'm not trying to start a flame war, only to try to tell you that numbers are stored in memory in base 2 [s]why floor works like that[/s]...vrld wrote:I'll let you respond to that yourself:zac352 wrote:Add 2^num_bits/2 to your number to see its unsigned equivalent.
Lua, I believe, has 4 bytes allocated to whole number storage. Not comlpetely sure.
Floor cuts the decimal point numbers off the base 2 end.With your ignorance you simply can't afford that arrogance.zac352 wrote:You don't know what you're talking about...
Hello, I am not dead.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: math.floor()
zac352, you have a tendency speak down to people, specially when you are on shaky grounds yourself. On this forum, asking things politely is ok. Ego-posts don't work particularly well. You should have noticed by now.
If you meant to make a joke (which are, by the way, quite used on these forums) it didn't sound like one. No one is amused.
And giniu, I expected more from you.
Now you both shake your hands and write 10 times an Arkanoid clone on the blackboard.
Now coming back on topic: What zac352 got wrong is that floats are completely separated from integers. Their memory representation and operations are waaay different. Lua uses IEE 754 for representing floats in memory.
Basically, floats have a "significand" part, that works similarly to integers, as well as an "exponent" part. The magnitude of a float number is calculated operating on those both parts at the same time.
This allows storing a bigger range of a number than if you only had one bit per base 2 digits (exponents allow 16-bits floats range to be from 10^-14 to 10^15). The trade-off is an increasing loss of precision, the bigger the exponents are. Also, operations with floats get much more complicated than their integer counterparts. Consider that a simple operation such as adding two floats has to cope with the fact that these floats can have completely different exponents.
This complication also extends to the float-to-integer conversion.
The point is that floats are represented rather differently from integers. math.floor is not just a matter of "cutting the decimal numbers of the base 2 field off" as zac352 believes.
If that helps, making that mistake is very common among newcomers.
If you meant to make a joke (which are, by the way, quite used on these forums) it didn't sound like one. No one is amused.
And giniu, I expected more from you.
Now you both shake your hands and write 10 times an Arkanoid clone on the blackboard.
Now coming back on topic: What zac352 got wrong is that floats are completely separated from integers. Their memory representation and operations are waaay different. Lua uses IEE 754 for representing floats in memory.
Basically, floats have a "significand" part, that works similarly to integers, as well as an "exponent" part. The magnitude of a float number is calculated operating on those both parts at the same time.
This allows storing a bigger range of a number than if you only had one bit per base 2 digits (exponents allow 16-bits floats range to be from 10^-14 to 10^15). The trade-off is an increasing loss of precision, the bigger the exponents are. Also, operations with floats get much more complicated than their integer counterparts. Consider that a simple operation such as adding two floats has to cope with the fact that these floats can have completely different exponents.
This complication also extends to the float-to-integer conversion.
The point is that floats are represented rather differently from integers. math.floor is not just a matter of "cutting the decimal numbers of the base 2 field off" as zac352 believes.
If that helps, making that mistake is very common among newcomers.
When I write def I mean function.
Re: math.floor()
Sowwy.kikito wrote:zac352, you have a tendency speak down to people, specially when you are on shaky grounds yourself. On this forum, asking things politely is ok. Ego-posts don't work particularly well. You should have noticed by now.
If you meant to make a joke (which are, by the way, quite used on these forums) it didn't sound like one. No one is amused.
And giniu, I expected more from you.
Now you both shake your hands and write 10 times an Arkanoid clone on the blackboard.
Now coming back on topic: What zac352 got wrong is that floats are completely separated from integers. Their memory representation and operations are waaay different. Lua uses IEE 754 for representing floats in memory.
Basically, floats have a "significand" part, that works similarly to integers, as well as an "exponent" part. The magnitude of a float number is calculated operating on those both parts at the same time.
This allows storing a bigger range of a number than if you only had one bit per base 2 digits (exponents allow 16-bits floats range to be from 10^-14 to 10^15). The trade-off is an increasing loss of precision, the bigger the exponents are. Also, operations with floats get much more complicated than their integer counterparts. Consider that a simple operation such as adding two floats has to cope with the fact that these floats can have completely different exponents.
This complication also extends to the float-to-integer conversion.
The point is that floats are represented rather differently from integers. math.floor is not just a matter of "cutting the decimal numbers of the base 2 field off" as zac352 believes.
If that helps, making that mistake is very common among newcomers.
I didn't read over the Lua source code like you did. XD
Hello, I am not dead.
Re: math.floor()
Is this textbox glitch I keep getting when quoting large posts a problem with IE on these computers? I don't get this issue on Firefox at home...
Hello, I am not dead.
Re: math.floor()
Now I feel like all that stuff I learned in that C++ tutorial is a lie. >_>
Hello, I am not dead.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: math.floor()
I didn't. I just googled 'Lua floating point'.zac352 wrote:I didn't read over the Lua source code like you did. XD
When I write def I mean function.
Re: math.floor()
That was a joke. ._.kikito wrote:I didn't. I just googled 'Lua floating point'.zac352 wrote:I didn't read over the Lua source code like you did. XD
Hello, I am not dead.
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 7 guests