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 » Developing U++ » U++ Developers corner » Value with type float
Re: Value with type float [message #60200 is a reply to message #60198] Fri, 06 October 2023 12:51 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14256
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 04 October 2023 12:08
mirek wrote on Wed, 04 October 2023 10:55
Just revisting this issue...

Tom1 wrote on Fri, 03 June 2022 12:03

- I can use Value with float as easily as with double without explicit type casts anywhere


Yes.

Quote:

- Assigning a float to Value reads back from Value exactly the same as it went in


If "reads back" means text output, then yes.

Quote:

- If EditFloat* is again replaced by EditDouble*, the behavior is exactly the same as it is now with EditFloat*


Should work.

Quote:

- float supports Null


No. Is that a problem?

Quote:

Maybe the precision hint you are suggesting could be automatically initialized in Value(double) / Value(float) constructors and assignment operators =(double) / =(float) to suit the assigned data type?


That was exactly the plan.

I think advantage of this solution is that it allows you to specify arbitrary precision for any double-holding Value. E.g.

	double x = 3.14159;
	Value json;
	json("pi") = Precision(x, 2); // Precision does not exist yet
	DDUMP(AsJSON(json));


{"pi":3.14}


Still an idea though.


Hi Mirek,

Thanks for the update on this subject.

For me 'reads back exactly the same' means binary equality:
float a = 1.234562f;
float b = 1.234562f;
Value c = b;
b = c;
if(a == b) Cout() << "Great, it works!\r\n"
else Cout() << "No, it does not read back the same...\r\n";




This works (and I believe it should) right now. Am I missing something?

Quote:


As for float Null, yes, please include the changes shown in:

https://www.ultimatepp.org/forums/index.php?t=msg&th=120 82&goto=59874&#msg_59874



I am reluctant adding yet another Null...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Build U++ with CMake and Clang Example
Next Topic: A temporary solution to garbled code in U++applications built through MSVC
Goto Forum:
  


Current Time: Thu May 01 01:18:04 CEST 2025

Total time taken to generate the page: 0.00839 seconds