1. Mohammad Almasri
  2. PowerBuilder
  3. Tuesday, 21 February 2023 10:00 AM UTC

Hi,

I am importing data from excel file and there is one important column coming as scientific format number 1.68E+19 how to convert it to text with correct result, I tried to convert excel cell format to number but given me like this format 16752100000000000000.

If you can support a way to fix it, even inside PowerBuilder or outsaid.

 

Thank you

 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 21 February 2023 11:12 AM UTC
  2. PowerBuilder
  3. # 1

Hi,

 

If you want less digits after the ".", you can strip out the numbers between the "." and the "E", convert it to a number, round it to the positions you want,  and reconstruct the full string. Something like that 

 

{Edit} With thanks to Arnd: you have to write a "." behind the number in the assignment of the double variable !!!! (crazy).

regards

Comment
  1. Miguel Leeuwe
  2. Tuesday, 21 February 2023 12:04 PM UTC
hmmm, the problem is maybe not the conversion to string but the double variable itself. From the PB help, a double should be capable to hold the number suggested by the OP though:



"Double

A signed floating-point number with 15 digits of precision and a range from 2.2250738585073E-308 to 1.79769313486231E+308, and -2.2250738585073E-308 to -1.79769313486231E+308."



But it's not working, updating my ticket ...

  1. Helpful
  1. Arnd Schmidt
  2. Tuesday, 21 February 2023 12:55 PM UTC
No Problem in PowerBuilder 10.5.

Remember to use a dot at the end of your number!

double ldbl_num = 16752100000000000000.

string ls_result

ls_result = String ( ldbl_num )

MessageBox("Test",ls_result)
  1. Helpful 1
  1. Miguel Leeuwe
  2. Tuesday, 21 February 2023 13:03 PM UTC
Hi Arnd,

Thank you very much! That indeed solves the problem.

It's my opinion though that it's ridiculous that we have to write the "." for this to work correctly!

Another quirk of Powerbuilder to remember!!!

Wow!
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 21 February 2023 11:06 AM UTC
  2. PowerBuilder
  3. # 2

I forgot to mention that if your number has a decimal part, then your formatting should be modified to show that part also.

Andreas.

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 21 February 2023 11:02 AM UTC
  2. PowerBuilder
  3. # 3

Hi.

Conversion should be done in excel. You cannot convert 1.68E+19 to the original number in PB as it contains roundings.

One thing you may try is to convert that number using excel's text function. This will show you a most accurate representation of your number. You can try to set in a cell something like that: =TEXT(C1;"000000000000000000000000000000").

Zeros in formatting should be the number following E+. In your case you should place in formatting 19 zeros. But as this is a scientific number, what you will see may also be a representation near to the real value...

Andreas.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.