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 #58232 is a reply to message #58228] Fri, 01 April 2022 11:07 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14256
Registered: November 2005
Ultimate Member
Tom1 wrote on Thu, 31 March 2022 13:49
Hi,

I could see some benefit for supporting float in Value too. (I do signal processing with floats, so they frequently end up in various locations in my code.)
Having Value supporting float and EditFloat/EditFloatSpin added would allow cleaner code with dialogs.

Currently I have to round the float value to a clean double with roundr() to avoid excessive decimal places in EditDouble/EditDoubleSpin display. Also, when reading the value out from EditDouble/EditDoubleSpin, I will need to cast first to (double) and only thereafter to (float).

As an example, I have filtering frequencies controlled with:
void SetHPF(float fc);
float GetHPF();

Filling the EditDoubleSpin:
hpf<<=roundr(GetHPF(),3);



Uhm, roundr is sort of sin of past. Perhaps it is a bad idea to pretend that either float or double are "decimal"...

That said, maybe we should just add operator float to Value and constructor from float (if that one is even needed)?

That would solve most of those additional casts that you do not like.

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:05:53 CEST 2025

Total time taken to generate the page: 0.03398 seconds