Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Value: why not float support?
Re: Value: why not float support? [message #30387 is a reply to message #30363] Mon, 27 December 2010 13:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kohait00 wrote on Sun, 26 December 2010 05:28


concerning double and float in databases: i'm sure the major db's *dont* simply convert it internally. at least not in terms of storage (millions and millions of rows with wasted 4 bytes for double, where float had been enough cant be aforded). thats why one generally is to think of a good, well fitting model/schema for one's problem, not to waste space and performance when handling the data.



No, that was not what I wanted to say. Of course, if you use 4B float in the DB schema, it gets stored as 4B value (unless you are using Oracle, which has very specific way of dealing with numbers anyway).

BUT all these floats can be moved at interface level to DB as doubles.

Which is sort of similar to what I recommend w.r.t. float in C++ code - only use it for storage...
Re: Value: why not float support? [message #30391 is a reply to message #30387] Mon, 27 December 2010 14:28 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
i dont mind handling float as double in cpu context, in functions etc. but in my case, sending and receiving is done with distinct types, float and double, unfortunately not interchangeable, it's compareable to storing things Smile.

well, my problem is actually, that i wanted to use Value as a cool implicit convertable container for arbitrary values (which it is). to save me the hassle of converting them manually, since a lot is already present. but lacking float makes it difficult to use in my case ofcorse. i might need to specify own converters which support float as well beeing a RichValue<>.

use case is indeed: an OSC Method handler receives i.e a Value as parameter, which is to be sent as float: so, if it is double, its converted, if it is int, also, if it's a String, it's tried to be parsed. etc.. thus the interface is really versatile and forgiving.

so i can set up different controls, that 'generate' internally different types (editfield a String, Option a bool/int value) but are sent as float etc.. so i dont need to care about types inside the controls already. i simply specify which type the OSC message should finally be sent as.


Re: Value: why not float support? [message #30392 is a reply to message #30391] Mon, 27 December 2010 14:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kohait00 wrote on Mon, 27 December 2010 08:28

i dont mind handling float as double in cpu context, in functions etc. but in my case, sending and receiving is done with distinct types, float and double, unfortunately not interchangeable, it's compareable to storing things Smile.

well, my problem is actually, that i wanted to use Value as a cool implicit convertable container for arbitrary values (which it is). to save me the hassle of converting them manually, since a lot is already present. but lacking float makes it difficult to use in my case ofcorse. i might need to specify own converters which support float as well beeing a RichValue<>.

use case is indeed: an OSC Method handler receives i.e a Value as parameter, which is to be sent as float: so, if it is double, its converted, if it is int, also, if it's a String, it's tried to be parsed. etc.. thus the interface is really versatile and forgiving.

so i can set up different controls, that 'generate' internally different types (editfield a String, Option a bool/int value) but are sent as float etc.. so i dont need to care about types inside the controls already. i simply specify which type the OSC message should finally be sent as.



Well, if I understood well what you have just wrote, I see it as argument NOT TO introduce 'float' into Value... Smile You can put float to Value now (as double). And you have to know the true signature of OSC method anyway, so that you can convert all parameters.

So introducing float would be no advantage here.

Mirek
Re: Value: why not float support? [message #30402 is a reply to message #30392] Tue, 28 December 2010 13:47 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
naah...that was not what i meant Smile
anyway, permit another question..

why does Value support int? int64 would do it just the same?
why bool? it's actually an int or even int64 for the cpu / compiler.

so breaking this down, the only meaningfull types would be double and int64, as representing the superset of possible types. which i suppose would be the perfect case.. but in terms of handling it'd be a nightmare, a lot of (int)myval, (bool)myval or myval = (double)myfloat and (int64)myint. why not have Value do all this mess?

if the user decides to represent it's data as double, or as float, or int or int64 he also decides on the resolution he needs, well knowing that this might 'implicitly' reduce some resolution, if coming from double precision i.e..

sorry to bother you with all that. i clearly can understand that you are not well with the thought of extending / breaking a working code just for the benefit of some marginal usecases. i'd do the same. mi point is, that i see a lot more potential in usage of Value than is currently possible. this is genious class that eases handling with types a LOT. but it needs some leverage of burdens.

just to demonstrate: i had to program a typed interface for a gui in our enterprise, and, just because i was 'scared' of Value, knowing it was not able to easy deal with float (because this is what our communication protocol uses the most) left it out to be used. instead, i took a templated approach, inveneted a custom database for objects, etc. etc.. now looking back, having better understood Value and having float support, i'd save me a LOOOT af work and headache.

generally, i'd recommend to enrich Value to support all types which differ in sizeof(), these are the signed variants.. this makes Value really attractive in usage in communication protocols.

bool
char
short
int
int64
float
double
Re: Value: why not float support? [message #31505 is a reply to message #30402] Mon, 07 March 2011 14:31 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
currently struggling with python incorporation in upp. and it's just to inform that python too, doesn't support float for the same reasons Smile

i'd love to stick with that but need a good idea on how to treat float in Value maybe simply avoid transformation...concerning sending and distinguishing double and float, i dont need it anyway and the rest (computation) can happen in double.

but the one question remains: why int and int64 both supported, why not mere int64 as superset? it's same as float and double..
Re: Value: why not float support? [message #31509 is a reply to message #31505] Mon, 07 March 2011 23:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kohait00 wrote on Mon, 07 March 2011 08:31


but the one question remains: why int and int64 both supported, why not mere int64 as superset? it's same as float and double..


Actually, it is for historic reasons more than anything else. We have started in 1998, back then int64 was something "special".

When it was proposed to add int64 (like in 2004 Smile, it was a good idea, but INT_V was left for BW compatibility.
Re: Value: why not float support? [message #31512 is a reply to message #31509] Tue, 08 March 2011 08:33 Go to previous message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
ok, that is logical Smile
thanks for the patience
Previous Topic: Core/Path.cpp: the limitation of GetCurrentDirectory for POSIX
Next Topic: InitCaps() proposal
Goto Forum:
  


Current Time: Mon Apr 29 10:44:38 CEST 2024

Total time taken to generate the page: 0.02960 seconds