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 » Weird result with Format();
Weird result with Format(); [message #60301] Tue, 14 November 2023 20:53 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I have spent considerable amount of time to understand what it is happening but with no result (U++ 17080 and clang in debug mode).

#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	float n = 3.0;
	String sscore;
	sscore = Format("%f", n);
	Cout()<<sscore<<"\n" ;
	
	sscore = AsString(n);
	Cout()<<sscore<<"\n" ;	
}


Result:
<N/A 'f' for type 13>
3

In release mode I get
3f
3

Does format has changed the way to work? It seems no longer recognise the "f" specifier.
Thanks,

Luigi
Re: Weird result with Format(); [message #60302 is a reply to message #60301] Tue, 14 November 2023 21:37 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
forlano wrote on Tue, 14 November 2023 20:53

Result:
<N/A 'f' for type 13>
3

In release mode I get
3f
3


on U++ 17045 I get the expected

3.000000
3

[Updated on: Tue, 14 November 2023 21:38]

Report message to a moderator

Re: Weird result with Format(); [message #60307 is a reply to message #60302] Wed, 15 November 2023 11:10 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
On the same machine I have installed the today 17088 that shows the same problem.
Then I have installed the stable 17045 that has not this problem.

Can somebody else confirm such problem?
Thanks,

Luigi
Re: Weird result with Format(); [message #60312 is a reply to message #60307] Fri, 17 November 2023 08:24 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3359
Registered: August 2008
Senior Veteran
Quote:
Can somebody else confirm such problem?
Yes, I get the same in Windows and Linux.


Best regards
IƱaki
Re: Weird result with Format(); [message #60313 is a reply to message #60307] Fri, 17 November 2023 18:41 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi,

I can confirm this too. I guess this is an unfortunate side effect of float recently gaining Value support.

In Core/Format.cpp it needs one or both of these additions:
...
void RegisterNumberFormatter(const char *id, Formatter f)
{
	RegisterFormatter(DOUBLE_V, id, f);
	RegisterFormatter(FLOAT_V, id, f);      // << Add float support
	RegisterFormatter(INT64_V, id, f);
	RegisterFormatter(INT_V, id, f);
	RegisterFormatter(BOOL_V, id, f);
	RegisterNullFormatter(id, f);
}
...


and/or

...
static void sRegisterFormatters()
{
	ONCELOCK {
		IntDoubleRegister(BOOL_V);
		IntDoubleRegister(INT_V);
		IntDoubleRegister(INT64_V);
		IntDoubleRegister(DOUBLE_V);
		IntDoubleRegister(FLOAT_V);      // << Add float support
...


I'm just guessing... Mirek knows for sure how to proceed.

Best regards,

Tom
Re: Weird result with Format(); [message #60315 is a reply to message #60313] Sat, 18 November 2023 09:39 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hopefully fixed, I have rescanned all places where DOUBLE_V is referenced and added support where needed...

https://github.com/ultimatepp/ultimatepp/commit/2afe7f538254 db288f9dafcd41c77757dccc3f3e

Mirek
Previous Topic: About recent memset optimization
Next Topic: Default comparisons for type derived from Moveable
Goto Forum:
  


Current Time: Sun May 05 02:19:59 CEST 2024

Total time taken to generate the page: 0.02723 seconds