Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (kzhao, AndrewAMD, bigsmack), 824 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: replace var with float and support var as float typedef [Re: JibbSmart] #337864
08/13/10 23:19
08/13/10 23:19
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
var is also impractical when it comes to vector calculations. Calculating dot products for example is only possible with small-magnitude vectors. This is indeed somewhat annoying. I neather want to typecast between float and var all the time, nor I want to use my own vector functions. AFAIK converting floating point numbers to integer types in C is (or was) for some reason a pretty slow process on Pentium machines. I don't know whether this still applies to lite-C, though.

However, Gamestudio has the reputation of being a program with very good backward compatibility. Replacing var with float will easily break this backward compatibility completely. var is not only used for fixed point numbers, but also for storing engine object handles and pointers. Entity skills are vars, too. So replacing alone won't do it.

Even though I would appreciate a change-over to standard C data types, I consider "abandoning the var type soon" unlikely at the moment. Might be a wrong estimate, though.

Re: replace var with float and support var as float typedef [Re: Saturnus] #337870
08/14/10 00:25
08/14/10 00:25
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
I wonder how realistic it would be to ask for a #define, then, that enabled the switch?

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: replace var with float and support var as float typedef [Re: JibbSmart] #337879
08/14/10 04:07
08/14/10 04:07
Joined: Mar 2002
Posts: 1,774
Magdeburg
F
FlorianP Offline
Serious User
FlorianP  Offline
Serious User
F

Joined: Mar 2002
Posts: 1,774
Magdeburg
definitely agree!
Never in history something was as unecessary as inventing the var-type.

Last edited by FlorianP; 08/14/10 04:14.

I <3 LINQ
Re: replace var with float and support var as float typedef [Re: Saturnus] #337889
08/14/10 07:47
08/14/10 07:47
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: Saturnus
Replacing var with float will easily break this backward compatibility completely. var is not only used for fixed point numbers, but also for storing engine object handles and pointers. Entity skills are vars, too. So replacing alone won't do it.


Float was just a suggestion because var's are used most often for numeric stuff. If you only have integer values - use integer. If you return pointers, return them in the appropriate format or use simply void* (e.g. for sound handles or do typedef void* SOUND_HANDLE or else).

Re: replace var with float and support var as float typedef [Re: HeelX] #337893
08/14/10 10:02
08/14/10 10:02
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Vars must be replaced with double, not float. Replacing them with float would lose precision with large numbers, so thats the opposite of what you want. But I think double will work for all coordinate ranges without losing precision.

It wont be backwards compatible of course, but rewriting scripts for double vars should be not to difficult. Sometimes it could be tricky but in most cases the vars only need to be replaced with int, or with pointers, depending on what you do with them.

Its similar to the step from C-Script to lite-C.

Re: replace var with float and support var as float typedef [Re: Tobias] #337903
08/14/10 11:06
08/14/10 11:06
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
with floats you don't need that big numbers though since they are much better suited for directly using them as (much more intuitive) meters instead of 32 quants = 1 meter, or 1 quant is 1 inch or something like that.

but if i remember correctly lite-c doesn't really fully support floats anyway (my memory about this is fuzzy but didn't a lot of stuff always require casting to double?) so doubles would be fine too. laugh

Re: replace var with float and support var as float typedef [Re: ventilator] #338483
08/18/10 14:43
08/18/10 14:43
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You would not like it when we replaced var with floats, and let you then deal with lots of problems like reduced precision, failing of comparison operations and so on. Rewriting your scripts would be a nightmare, much worse than the rewriting WDL code to C. Vars will stay.

But using floats and doubles for vector and matrix operations makes a lot of sense and you're free to do that - the whole DirectX vector and matrix library can be used with lite-C. The function list can be found in the DirectX documentation. The DirectX functions are sometimes even faster than their vec_ counterparts.

Re: replace var with float and support var as float typedef [Re: jcl] #338490
08/18/10 15:00
08/18/10 15:00
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Ok, that makes some sense. But could you at least overload some functions, that internally cast the vars to other types anyway, such as e.g. file_asc_write, where char would make much more sense?

Re: replace var with float and support var as float typedef [Re: Lukas] #338573
08/19/10 10:06
08/19/10 10:06
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
All C languages automatically convert numbers and numerical variables. You don't need overloading for this.

Re: replace var with float and support var as float typedef [Re: jcl] #338585
08/19/10 11:52
08/19/10 11:52
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
I know, but it kind of feels wrong to take a char, cast it to var, and then cast it back to char. This is also a small performance loss.

Page 2 of 2 1 2

Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1