wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-29-2009, 03:38 AM   #1
Feroc1ty
User
 
Join Date: Nov 2006
Posts: 304

Feroc1ty is on a distinguished road (14)

Default dividing by 1 is a special case

Collapse JASS:
call BJDebugMsg(R2S(209817650/1.00))

Last edited by Feroc1ty : 04-29-2009 at 03:39 AM.
Feroc1ty is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-29-2009, 04:31 AM   #2
MaD[Lion]
MaD Da ViNci
 
MaD[Lion]'s Avatar


Respected User
 
Join Date: Apr 2003
Posts: 1,699

Submissions (10)

MaD[Lion] is a jewel in the rough (225)MaD[Lion] is a jewel in the rough (225)MaD[Lion] is a jewel in the rough (225)MaD[Lion] is a jewel in the rough (225)

Default

wat is so special about it, dont just post code, not all can be arsed to test just 1 line.
__________________
Current Projects:
MaDOS (outdated)System for object movements & effects - NEW VERSION IS UNDER W.I.P
Cinematic SystemSystem for making better cinematics and with fancy effects
Timing SystemTiming system that simulates the usage of PolledWait just with 0.01 accuracy
MaD[Lion] is offline   Reply With Quote
Old 04-29-2009, 05:20 AM   #3
PipeDream
Moderator
 
PipeDream's Avatar


Code Moderator
 
Join Date: Feb 2006
Posts: 1,405

Submissions (6)

PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)

Default

Yes, floating point arithmetic is weird, particularly so because warcraft's implementation is broken.

http://en.wikipedia.org/wiki/IEEE_fl...point_standard

Several good references at the bottom. I don't know if it's technical or historical, but Kahan is sure to be interesting.
__________________
PipeDream is offline   Reply With Quote
Old 04-29-2009, 05:22 AM
Vexorian
This message has been deleted by Vexorian. Reason: bah
Old 04-29-2009, 05:49 AM   #4
Feroc1ty
User
 
Join Date: Nov 2006
Posts: 304

Feroc1ty is on a distinguished road (14)

Default

Apparently 209817650 divided by 1 is 209817648.
Feroc1ty is offline   Reply With Quote
Old 04-29-2009, 07:29 AM
Litany
This message has been deleted by Litany.
Old 04-29-2009, 07:46 AM   #5
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,153

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

Quote:
Originally Posted by Litany
It's specific to reals, so 209817650 / 1. = 209817648. Unless you're directly comparing this probably isn't going to be an issue, but if you need something like 1. + .05 - .05 = 1., it sucks. Not only are the numbers off, but the two reals don't even cancel each other out. You can work around this to some extent by converting to strings and comparing those instead--for example, 1. + .05 = 1.049999952, while R2S(1. + .05) = "1.05"--but this will bog down your map if you do it a lot. Hooray for strings in WC3.

why not R2I(yourReal1*ACCURACY)==R2I(yourReal2*ACCURACY)...
or RAbs(yourReal1-yourReal2)<ACCURACY ..thats obviously a lot better than the massive usage of strings
__________________
akolyt0r is offline   Reply With Quote
Old 04-29-2009, 10:36 AM
Litany
This message has been deleted by Litany.
Old 04-29-2009, 10:48 AM   #6
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,153

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

with a accuracy-multiplicator of 10 to 100 the R2I thing would work quite anyway ..and you dont need that much of accuracy anyway most of the time...
__________________
akolyt0r is offline   Reply With Quote
Old 04-29-2009, 12:11 PM
Litany
This message has been deleted by Litany.
Old 04-29-2009, 12:22 PM   #7
Toadcop
BuranX
 
Toadcop's Avatar
 
Join Date: Jul 2006
Posts: 1,886

Submissions (4)

Toadcop is just really nice (299)Toadcop is just really nice (299)

Approved Map: TcXSpell Making Session 10 Winner

Send a message via ICQ to Toadcop
Default

imo it's obvious... you can't store something in 32 bit and not to loose precision. (if it's not an 32 bit integer)
so it just another
__________________
Toadcop is offline   Reply With Quote
Old 04-29-2009, 06:35 PM   #8
Feroc1ty
User
 
Join Date: Nov 2006
Posts: 304

Feroc1ty is on a distinguished road (14)

Default

Quote:
Originally Posted by Toadcop
imo it's obvious... you can't store something in 32 bit and not to loose precision. (if it's not an 32 bit integer)
so it just another

Dividing or multiplying by 1 is some srs business.
Feroc1ty is offline   Reply With Quote
Old 04-29-2009, 09:16 PM
Litany
This message has been deleted by Litany.
Old 04-29-2009, 09:32 PM   #9
cosmicat
Probably AFK
 
cosmicat's Avatar
 
Join Date: Feb 2009
Posts: 635

cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)

Default

I think it has more to do with the fact that 209817650 simply can't be stored accurately in a 32-bit real. That is, perhaps it remains accurate if nothing changes, but dividing/multiplying by 1 is still an operation.
__________________
+++++++++++[>++++++>++++++++++>++++++++++<<<-]>+.>+.++++.+>-.----.------.--.<.

Last edited by cosmicat : 04-29-2009 at 09:33 PM.
cosmicat is offline   Reply With Quote
Old 04-30-2009, 01:11 AM
Litany
This message has been deleted by Litany.
Old 04-30-2009, 01:45 AM   #10
cosmicat
Probably AFK
 
cosmicat's Avatar
 
Join Date: Feb 2009
Posts: 635

cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)

Default

How is that surprising? That's about the same precision Java has, too. C++ is capable of more, but it's system-dependent while Java and Jass have to be portable (i.e. Warcraft has to show the same result for every user, C++ does not - necessarily).

What's surprising is that you folks aren't thinking in binary. 209817650. = 13113603*(2^4) + 2.

Dec(13113603) = Bin(101000000001010000000110010000001100100000011)

That's really amazing precision - at least 48 bits, which is surprising in a good way (I suppose it's possible that long strings of zeroes are represented by something other than long strings of zeroes to save bit space, which would bring down the precision a bit...).
So probably at least 3-7 bits are reserved for information about the location of the floating point and the power 2 to multiply the number represented by.

Compare:
###101000000001010000000110010000001100100000011
###1010000000010100000001100100000011001000000110010

Yep, assuming a certain amount of space is reserved for general information about the real itself, this is really pretty amazingly precise.
__________________
+++++++++++[>++++++>++++++++++>++++++++++<<<-]>+.>+.++++.+>-.----.------.--.<.
cosmicat is offline   Reply With Quote
Old 04-30-2009, 02:10 AM   #11
Mr_Saturn
User
 
Join Date: Nov 2003
Posts: 27

Mr_Saturn has little to show at this moment (5)

Default

I always assumed a real was a double. Goddamn floats.
Mr_Saturn is offline   Reply With Quote
Old 04-30-2009, 02:28 AM
Litany
This message has been deleted by Litany.
Old 04-30-2009, 03:15 AM   #12
PipeDream
Moderator
 
PipeDream's Avatar


Code Moderator
 
Join Date: Feb 2006
Posts: 1,405

Submissions (6)

PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)

Default

Quote:
Originally Posted by Mr_Saturn
I always assumed a real was a double. Goddamn floats.

All warcraft types are dwords
__________________
PipeDream is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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


All times are GMT. The time now is 06:55 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services