Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Bug Report
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #16  
Old 01-27-2009, 02:49 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
Quote:
Originally Posted by LoneAngelIbesu View Post
It's probably more complex than you think it is. PHP is a very good language. The point I was trying to make, though, was that you should try and not use non-terminating decimals, or at least round them to terminating decimals.

Using large decimals is bound to cause problems. For instance, in GS2 "7.999969482 - 8" produces 0. But, "7.99 - 8" produces -0.01. So, I wouldn't say that int() is useless. It just faces the same problems that other languages face when it comes to floating points.
I'd love to, but it's difficult to determine if the bitflag 262143 contains 32768 (2^15th) or not without doing a little division.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #17  
Old 01-27-2009, 03:20 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Loriel View Post
Nice theory, except booth floor and intval get 262143/32768 right.
In PHP, maybe. We're talking about GS2 here, so we have to assume that it's going to screw up easily with large decimals, as seen when it can't correctly subtract 8 from 7.999969482. Obviously, it's rounding 7.999969482 to 8, which is also why int(7.999969482) returns 8 instead of 7.

I did a quick test on RC. int(7.999) returns 7, but int(7.9999) returns 8. int(7.9998) returns 7, as well as int(7.999899999). Considering that 7.9999 and 7.999969482 have one thing in common, it's safe to assume that when Graal sees ".9999", it'll round up to the nearest whole number.

Quote:
Originally Posted by Tyhm View Post
I'd love to, but it's difficult to determine if the bitflag 262143 contains 32768 (2^15th) or not without doing a little division.
What are you trying to accomplish, exactly? Perhaps if you showed us the problem in context, somebody might be able to figure something out (unless you're fine with using your work-around).
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #18  
Old 01-27-2009, 04:24 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Tyhm View Post
I'd love to, but it's difficult to determine if the bitflag 262143 contains 32768 (2^15th) or not without doing a little division.
if ((262143 & 32768) != 0), no?
Reply With Quote
  #19  
Old 01-27-2009, 06:16 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
Huh. & might work, never tried it before;
The way I've got it set up Now is, it keeps an array of rooms that connect to other rooms; the array index is the room in question, the value at that index is a bitflag of which rooms it connects to (1 means 1, 2 means 2 and not 1, 3 means 2 and 1, 4 means 3, 5 means 3 and 1, etc). When it links two rooms it simply adds the values to combine the list of linked rooms, and then updates not just those 2 rooms but every room that links to those 2 rooms.

Moral of the story is, & might work for me, but it's not gonna make me happy; what, I have to revise every int(random(0,2)) now to have a special case for if it returns 2?!
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #20  
Old 01-27-2009, 11:10 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Skyld View Post
if ((262143 & 32768) != 0), no?
I've never noticed that kind of syntax in GS2 (single ampersand)...
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #21  
Old 01-27-2009, 11:27 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by LoneAngelIbesu View Post
I've never noticed that kind of syntax in GS2 (single ampersand)...
It's very practical

PHP Code:
function onCreated() {
  
temp.bit 2+4+16;

  if (
bit 2) echo("2");
  if (
bit 4) echo("4");
  if (
bit 8) echo("8");
  if (
bit 16) echo("16");

Echoes

Quote:
2
4
16
(move() uses this)
__________________
Reply With Quote
  #22  
Old 01-27-2009, 11:49 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Pseudo-bitwise operation on what amounts to floating point numbers are a bit scary.
Reply With Quote
  #23  
Old 01-28-2009, 06:49 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Interesting stuff on the whole rounding issue to anyone who is interested: http://wiki.php.net/rfc/rounding
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:57 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.