Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert a string to Double

1,016 views
Skip to first unread message

Hans Schmid

unread,
Nov 10, 1998, 3:00:00 AM11/10/98
to
Hi all,

we have experienced a problem when converting a string to a double:

double ld_value
string ls_value

ls_value = '73.15'

ld_value = Double ( ls_string)

-> results in 73.00

The string 73.15 was entered in a SingleLineEdit.

The weird thing is, that it worked on UK settings but not on German settings
(speaking about Windows Regional Settings).

We need this for Price calculations (EURO stuff).

Any ideas ??

Best regards,
Hans Schmid


Our Platform: Win 95 and NT 4 SP3
Powerbuilder 6.0 build 419

Ivo Abeloos

unread,
Nov 10, 1998, 3:00:00 AM11/10/98
to
Hi Hans,

>
>we have experienced a problem when converting a string to a double:
>
>double ld_value
>string ls_value
>
>ls_value = '73.15'
>
>ld_value = Double ( ls_string)
>
>-> results in 73.00
>
>The string 73.15 was entered in a SingleLineEdit.
>
>The weird thing is, that it worked on UK settings but not on German
settings
>(speaking about Windows Regional Settings).
>
>We need this for Price calculations (EURO stuff).
>
>Any ideas ??
>


This is a bug in Powerbuilder 6.0 and 6.5, already patched in one of their
patches.

Ciao,

Ivo

Eric Aling [TeamPS]

unread,
Nov 11, 1998, 3:00:00 AM11/11/98
to
Hi Hans,

I remember this as a bug. Which version of PB are you using (are you using
the latest maintenance release?)

--
- Eric Aling [TeamPS], Cypres Informatisering bv, The Netherlands
Eric's Home & PB Site @ http://utopia.knoware.nl/users/cypr115


Hans Schmid <Hans....@compaq.com> wrote in message
S0tR#5LD#GA...@forums.powersoft.com...
>Hi all,


>
>we have experienced a problem when converting a string to a double:
>
>double ld_value
>string ls_value
>
>ls_value = '73.15'
>
>ld_value = Double ( ls_string)
>
>-> results in 73.00
>
>The string 73.15 was entered in a SingleLineEdit.
>
>The weird thing is, that it worked on UK settings but not on German
settings
>(speaking about Windows Regional Settings).
>
>We need this for Price calculations (EURO stuff).
>
>Any ideas ??
>

Hans Schmid

unread,
Nov 11, 1998, 3:00:00 AM11/11/98
to
Eric,

Thanks for the quick response.

We officially have to use Powerbuilder 6.0 here in our project (enforced by
the company).
Nevertheless, we have rolled out the following DLL's together with our EXE:

PBMSS60.DLL (6.0.01.419)
PBDWE60.DLL (6.0.01.419)
PBVM60.DLL (6.0.01.419)

We tested the 444 dlls as well and had problems (the original 6.0 dlls, I
think 253) both had problems.


Does this work with Powerbuilder 6.5 ?

Best Regards, Hans

Eric Aling [TeamPS] wrote in message ...

Eric Aling [TeamPS]

unread,
Nov 11, 1998, 3:00:00 AM11/11/98
to
Hi Hans,,

6.0 already. I thought it was a 5x bug. I would suggest you test it with
6.5. If it is then not working, report it to Sybase Germany.

--
- Eric Aling [TeamPS], Cypres Informatisering bv, The Netherlands
Eric's Home & PB Site @ http://utopia.knoware.nl/users/cypr115


Hans Schmid <Hans....@compaq.com> wrote in message

DDiimVUD#GA....@forums.powersoft.com...

Juraj Suja

unread,
Nov 11, 1998, 3:00:00 AM11/11/98
to
Sorry I haven't noticed this message earlier. Please see my message: "Q -
Double() function trouble in PB6.5" I posted a few minutes ago.

The problem with converting a string into a double variable exists in PB6.5
when using Double() function as well.
According to my testing it occurs regardless of a Country specified in the
Windows regional settings and it seems to be related only to the Windows
regional settings for Number - Decimal Separator, i.e. if it's a comma then
it will chop off the decimal portion of the converted string.

Our Platform: WIN95 & WINNT SP3
PowerBuilder 6.5 build 444

Juraj
ju...@morganlabs.com


Eric Aling [TeamPS] wrote in message

<3q6pcnWD#GA....@forums.powersoft.com>...

Eric Aling [TeamPS]

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to
See my other reply to your message...

--
- Eric Aling [TeamPS], Cypres Informatisering bv, The Netherlands
Eric's Home & PB Site @ http://utopia.knoware.nl/users/cypr115


Juraj Suja <ju...@morganlabs.com> wrote in message
aspVuAbD#GA....@forums.powersoft.com...

Hans Schmid

unread,
Nov 12, 1998, 3:00:00 AM11/12/98
to
Hi,

the problem we are facing with your suggestion to replace the ',' with a '.'
are the thousend seperators.

Currently we use our own routine and do not allow thousand seperators.
This is really a pain fo the Italians.

this small difference of
1000000000 Lira
and 100000000 Lira is quite a lot !

Imagine Users to count Zeros if they can not use thousand seperators
1.000.000.000 resp. 100.000.000

Regards, Hans

Eric Aling [TeamPS] wrote in message ...

Brad Mettee

unread,
Nov 13, 1998, 3:00:00 AM11/13/98
to
In article <n5Xkr2jD#GA....@forums.powersoft.com>,
Hans....@compaq.com says...

>the problem we are facing with your suggestion to replace the ',' with a '.'
>are the thousend seperators.
>
>Currently we use our own routine and do not allow thousand seperators.
>This is really a pain fo the Italians.
>
>this small difference of
> 1000000000 Lira
>and 100000000 Lira is quite a lot !
>
>Imagine Users to count Zeros if they can not use thousand seperators
>1.000.000.000 resp. 100.000.000

It should be possible to dig through the registry, pick up the current
thousands/decimal characters, and write a parse routine to turn it into a double
yourself.

Find the "decimal" from the right of the string.
Take all characters from it + 1 to end of string and save as real.
Convert remainder of string from left to, but not including decimal, and convert to
double.
Add to the double, the real divided by 10 ^ numchars in real.

Sample pseudo code:

function FixedDouble(string input)
String remainder
Double output

remainder = mid(input, pos(input, decimal_seperator) + 1) // take to end of line
ouput = double(left(input, pos(input, decimal_seperator) - 1)
output = output + real(remainder) / (10 ^ len(remainder))

return output

Looks like it should work, all you need to do is figure out what the decimal
seperator should be based on current language settings. Oh, and some sanity
checks too.

Hope this helps,

--
Brad Mettee
PC HotShots, Inc.
Baltimore, MD

--> Let us bring out the *Power* of your PCs <--
* finger bme...@clark.net for PGP Key *


FORMAUX Marc

unread,
Nov 16, 1998, 3:00:00 AM11/16/98
to
This solution is everything but simple ...
and what about a fix by Sybase itself ???
some msgs ago, i read:
    6.0 already. I thought it was a 5x bug. I would suggest you test it with
    6.5. If it is then not working, report it to Sybase Germany.
    --
    - Eric Aling [TeamPS], Cypres Informatisering bv, The Netherlands

If this is a long time known bug, why is it always in 6.5 ?
 

Brad Mettee a écrit:

0 new messages