forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Negative zero??

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
dingo



Joined: 17 Nov 2005
Posts: 2

PostPosted: Thu Nov 17, 2005 6:00 am    Post subject: Negative zero?? Reply with quote

Hello.. First post here.
I noticed an odd bug in luaplayer while working on my complex number calculator. Someone must have surely noticed this, but I've tried searching and I've not found anything.
According to Luaplayer, -1*0 = -0..
Here's the code I've tested it with:
Code:
zero = 0*-1
screen:fillRect(0,0,480,272,Color.new(0,0,0))
screen:print(200,100,tostring(zero),Color.new(255,255,255))
screen:print(200,110,tostring(zero == 0), Color.new(255,255,255))

screen:flip()

while true do
   screen.waitVblankStart()
end


it outputs this:
-0
true

which I guess means -0 has a different value to 0, but is still equal to it.

I'm using user-mode lua (for 2.0 fw) and I've also tested it on the luaplayer for windows alpha.
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Thu Nov 17, 2005 6:51 am    Post subject: Reply with quote

Floating point numbers have both +0 and -0. It's mostly of use to people trying to perform analytical calculations. One example is it can be used to find out if a numerical series converges to 0 and if it approached from above (+0) or below (-0).

It's not a lua bug and you probably shouldn't need to worry about it.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
dingo



Joined: 17 Nov 2005
Posts: 2

PostPosted: Sat Nov 19, 2005 4:43 am    Post subject: Reply with quote

Ooh OK, thanks for explaining that..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot 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