|
|
Home » U++ Library support » U++ SQL » Huge error of Postgresql! Double fields by transmission to the program lose a fractional part!
Re: Huge error of Postgresql! Double fields by transmission to the program lose a fractional part! [message #47537 is a reply to message #47536] |
Thu, 26 January 2017 01:43   |
|
But if I start
LC_ALL=en_US.UTF-8 ./ProgramName
or
LANG=en_US.UTF-8 ./ProgramName
than all correct.
26.01.2017 03:41:15 ===start analysis===
26.01.2017 03:41:15 s = 40
26.01.2017 03:41:15 da = 40
26.01.2017 03:41:15 dS = 40
26.01.2017 03:41:15 test_format_and_lang_settings = 40.000000
26.01.2017 03:41:15 ====end analysis====
26.01.2017 03:41:15
26.01.2017 03:41:15 ===start analysis===
26.01.2017 03:41:15 s = 269.96336996337
26.01.2017 03:41:15 da = 269.96336996337
26.01.2017 03:41:15 dS = 269.96336996337
26.01.2017 03:41:15 test_format_and_lang_settings = 269.963370
26.01.2017 03:41:15 ====end analysis====
26.01.2017 03:41:15
26.01.2017 03:41:15 ===start analysis===
26.01.2017 03:41:15 s = 59.95115995116
26.01.2017 03:41:15 da = 59.95115995116
26.01.2017 03:41:15 dS = 59.95115995116
26.01.2017 03:41:15 test_format_and_lang_settings = 59.951160
26.01.2017 03:41:15 ====end analysis====
26.01.2017 03:41:15
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
[Updated on: Thu, 26 January 2017 01:50] Report message to a moderator
|
|
|
|
Re: Huge error of Postgresql! Double fields by transmission to the program lose a fractional part! [message #47539 is a reply to message #47538] |
Thu, 26 January 2017 01:57   |
|
Postgresql (Server v. 9.5) language settings are default.
fragment of postgres config:
# These settings are initialized by initdb, but they can be changed.
lc_messages = 'ru_RU.UTF-8' # locale for system error message
# strings
lc_monetary = 'ru_RU.UTF-8' # locale for monetary formatting
lc_numeric = 'ru_RU.UTF-8' # locale for number formatting
lc_time = 'ru_RU.UTF-8' # locale for time formatting
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: Huge error of Postgresql! Double fields by transmission to the program lose a fractional part! [message #47540 is a reply to message #47539] |
Thu, 26 January 2017 02:04   |
|
I change postgresql setting to ( /etc/postgresql/9.5/main/postgresql.conf )
en_US:
# These settings are initialized by initdb, but they can be changed.
#lc_messages = 'ru_RU.UTF-8' # locale for system error message
# strings
#lc_monetary = 'ru_RU.UTF-8' # locale for monetary formatting
#lc_numeric = 'ru_RU.UTF-8' # locale for number formatting
#lc_time = 'ru_RU.UTF-8' # locale for time formatting
lc_messages = 'en_US.UTF-8' # locale for system error message
# strings
lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
lc_numeric = 'en_US.UTF-8' # locale for number formatting
lc_time = 'en_US.UTF-8' # locale for time formatting
Result is zero!
26.01.2017 03:59:52 ===start analysis===
26.01.2017 03:59:52 s = 40
26.01.2017 03:59:52 da = 40
26.01.2017 03:59:52 dS = 40
26.01.2017 03:59:52 test_format_and_lang_settings = 40,000000
26.01.2017 03:59:52 ====end analysis====
26.01.2017 03:59:52
26.01.2017 03:59:52 ===start analysis===
26.01.2017 03:59:52 s = 269.96336996337
26.01.2017 03:59:52 da = 269
26.01.2017 03:59:52 dS = 269.96336996337
26.01.2017 03:59:52 test_format_and_lang_settings = 269,963370
26.01.2017 03:59:52 ====end analysis====
26.01.2017 03:59:52
26.01.2017 03:59:52 ===start analysis===
26.01.2017 03:59:52 s = 59.95115995116
26.01.2017 03:59:52 da = 59
26.01.2017 03:59:52 dS = 59.95115995116
26.01.2017 03:59:52 test_format_and_lang_settings = 59,951160
26.01.2017 03:59:52 ====end analysis====
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: Huge error of Postgresql! Double fields by transmission to the program lose a fractional part! [message #47541 is a reply to message #47540] |
Thu, 26 January 2017 02:23   |
|
I test timings:
Test code:
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
double a;
String s = "269.96336996337";
#define LOOPS 1000000
for(int i = 0; i < LOOPS; i++){
RTIMING("Using atof");
a = atof(s);
}
for(int i = 0; i < LOOPS; i++){
RTIMING("Using ScanDouble");
a = ScanDouble(s);
}
}
TIMING results:
TIMING Using ScanDouble: 1.12 s - 1.12 us ( 1.22 s / 1000000 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 1000000
TIMING Using atof : 337.45 ms - 337.45 ns (439.00 ms / 1000000 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 1000000
It's not dramatically slower! But standard settings (on various environments) show right results!
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
|
Re: Huge error of Postgresql! Double fields by transmission to the program lose a fractional part! [message #47544 is a reply to message #47541] |
Thu, 26 January 2017 14:10   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
sergeynikitin wrote on Thu, 26 January 2017 02:23I test timings:
Test code:
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
double a;
String s = "269.96336996337";
#define LOOPS 1000000
for(int i = 0; i < LOOPS; i++){
RTIMING("Using atof");
a = atof(s);
}
for(int i = 0; i < LOOPS; i++){
RTIMING("Using ScanDouble");
a = ScanDouble(s);
}
}
TIMING results:
TIMING Using ScanDouble: 1.12 s - 1.12 us ( 1.22 s / 1000000 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 1000000
TIMING Using atof : 337.45 ms - 337.45 ns (439.00 ms / 1000000 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 1000000
It's not dramatically slower! But standard settings (on various environments) show right results!
BTW, have you tried in Release? MSC14 32-bit release I am getting:
TIMING Using ScanDouble: 120.72 ms - 120.72 ns (148.00 ms / 1000000 ), min: 0.00 ns, max: 2.00 ms, nesting: 1 - 1000000
TIMING Using atof : 281.72 ms - 281.72 ns (309.00 ms / 1000000 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 1000000
I really would not like U++ being slower... 
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 28 20:32:47 CEST 2025
Total time taken to generate the page: 0.03752 seconds
|
|
|