0

I'm using an API that passes data from Python to Java. My issue is the Java does not like e notation. I get an illegal character exception. So I need to format my input such that there is no e in it. I'm using Python 2.7; if a newer version would help I could move up.

Decimal doesn't work (w=1e-8, e = w*100000000):

>>>Decimal(e)/Decimal(1)

Decimal('1')

>>>Decimal(e)/Decimal(100000000)

Decimal('1E-8')

>>>Decimal(w)/Decimal(1)

Decimal('1.000000000E-8')

String formatting doesn't work:

>>>print "%.16f" % w

0.0000000100000000

>>>s = "%.16f" % w

>>>Decimal(s)

Decimal('1.00000000E-8')

Float doesn't work; is there a way? I don't have access to the Java code so I can't cast it on that side. Thanks!

Community
  • 1
  • 1

0 Answers0