Thread: [cx-oracle-users] Cx_Oracle - Rounding Problem
Brought to you by:
atuining
From: Roberto B. I. <bet...@ho...> - 2011-01-18 18:23:59
|
Hello, My name is Roberto, Im new with all the stuff of Cx_Oracle. I'm working with Python 2.7 S.O. Windows Server 2003 Well, my problem is that when I'm doing a query to the database i have a column with a big float number but when I print my object I see that my numbers are rounded , what can I do ? I need the number with no rounding , please help me I'm new with this stuff. |
From: Anurag C. <anu...@gm...> - 2011-01-18 19:22:16
|
cx_Oracle fetches the value as it is in the DB for me. For example, I have a value of 26.3672 in the DB and it appears as it is.......Below is my code snippet. >>> query="select unit_vol from item" >>> cursor.execute(str(query)) >>> A=cursor.fetchall() >>> B=A[0][0] >>> print B 26.3672 It could be that you are doing some Type Conversion Un-Intentionally in your Python Code. Please post your code snippet along with the value that you have in DB so that we can help you further. Regards, Anurag On Tue, Jan 18, 2011 at 11:53 PM, Roberto Badillo Ibarra < bet...@ho...> wrote: > > Hello, > > My name is Roberto, Im new with all the stuff of Cx_Oracle. > > I'm working with Python 2.7 > S.O. Windows Server 2003 > > Well, my problem is that when I'm doing a query to the database i have a > column with a big float number but when I print my object I see that my > numbers are rounded , what can I do ? I need the number with no rounding , > please help me > > I'm new with this stuff. > > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > |
From: Roberto B. I. <bet...@ho...> - 2011-01-18 19:52:09
|
Hi, Well , when i have a float number with different numbers from 9 is ok, but when i have a number like 99345999999.9999 let me show you my problem For example, I have a value of 99345999999.9999 in the DB >>> query="select number from Data" >>> cursor.execute(str(query))>>> A=cursor.fetchall()>>> B=A[0][0]>>> print B 99346000000.0 I dont know why the object on Python script is rounding my float numbers. I dont want to print or save in a variable this value=99346000000.0 , I want 99345999999.9999 Please Help Me From: anu...@gm... Date: Wed, 19 Jan 2011 00:06:16 +0530 Subject: Re: [cx-oracle-users] Cx_Oracle - Rounding Problem To: cx-...@li...; bet...@ho...; ama...@gm...; jb...@gm...; ant...@gm... cx_Oracle fetches the value as it is in the DB for me. For example, I have a value of 26.3672 in the DB and it appears as it is.......Below is my code snippet. >>> query="select unit_vol from item" >>> cursor.execute(str(query))>>> A=cursor.fetchall()>>> B=A[0][0]>>> print B26.3672 It could be that you are doing some Type Conversion Un-Intentionally in your Python Code. Please post your code snippet along with the value that you have in DB so that we can help you further. Regards,Anurag On Tue, Jan 18, 2011 at 11:53 PM, Roberto Badillo Ibarra <bet...@ho...> wrote: Hello, My name is Roberto, Im new with all the stuff of Cx_Oracle. I'm working with Python 2.7 S.O. Windows Server 2003 Well, my problem is that when I'm doing a query to the database i have a column with a big float number but when I print my object I see that my numbers are rounded , what can I do ? I need the number with no rounding , please help me I'm new with this stuff. ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ cx-oracle-users mailing list cx-...@li... https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |
From: Anurag C. <anu...@gm...> - 2011-01-18 20:15:02
|
This is easily done in Python. Please use the fetched value in the manner that I have indicate below and see if it helps your cause. >>> A=cursor.fetchall() >>> B=A[0][0] >>> print B 346000000.0 >>> B.real 345999999.9999 Regards, Anurag On Wed, Jan 19, 2011 at 1:22 AM, Roberto Badillo Ibarra < bet...@ho...> wrote: > Hi, > > Well , when i have a float number with different numbers from 9 is ok, but > when i have a number like 99345999999.9999 let me show you my problem > > For example, I have a value of 99345999999.9999 in the DB > > >>> query="select number from Data" > >>> cursor.execute(str(query)) > >>> A=cursor.fetchall() > >>> B=A[0][0] > >>> print B > 99346000000.0 > > I dont know why the object on Python script is rounding my float numbers. > > I dont want to print or save in a variable this value=99346000000.0 , I > want 99345999999.9999 > > Please Help Me > > > ------------------------------ > From: anu...@gm... > Date: Wed, 19 Jan 2011 00:06:16 +0530 > Subject: Re: [cx-oracle-users] Cx_Oracle - Rounding Problem > To: cx-...@li...; bet...@ho...; > ama...@gm...; jb...@gm...; ant...@gm... > > > cx_Oracle fetches the value as it is in the DB for me. > > For example, I have a value of 26.3672 in the DB and it appears as it > is.......Below is my code snippet. > > >>> query="select unit_vol from item" > >>> cursor.execute(str(query)) > >>> A=cursor.fetchall() > >>> B=A[0][0] > >>> print B > 26.3672 > > It could be that you are doing some Type Conversion Un-Intentionally in > your Python Code. > > Please post your code snippet along with the value that you have in DB so > that we can help you further. > > Regards, > Anurag > > On Tue, Jan 18, 2011 at 11:53 PM, Roberto Badillo Ibarra < > bet...@ho...> wrote: > > > Hello, > > My name is Roberto, Im new with all the stuff of Cx_Oracle. > > I'm working with Python 2.7 > S.O. Windows Server 2003 > > Well, my problem is that when I'm doing a query to the database i have a > column with a big float number but when I print my object I see that my > numbers are rounded , what can I do ? I need the number with no rounding , > please help me > > I'm new with this stuff. > > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > > |
From: Roberto B. I. <bet...@ho...> - 2011-01-18 19:54:47
|
Sorry, i forget to tell you that on Python I'm just Printing the Object, So I know that the problem is not on Python. From: anu...@gm... Date: Wed, 19 Jan 2011 00:06:16 +0530 Subject: Re: [cx-oracle-users] Cx_Oracle - Rounding Problem To: cx-...@li...; bet...@ho...; ama...@gm...; jb...@gm...; ant...@gm... cx_Oracle fetches the value as it is in the DB for me. For example, I have a value of 26.3672 in the DB and it appears as it is.......Below is my code snippet. >>> query="select unit_vol from item" >>> cursor.execute(str(query))>>> A=cursor.fetchall()>>> B=A[0][0]>>> print B26.3672 It could be that you are doing some Type Conversion Un-Intentionally in your Python Code. Please post your code snippet along with the value that you have in DB so that we can help you further. Regards,Anurag On Tue, Jan 18, 2011 at 11:53 PM, Roberto Badillo Ibarra <bet...@ho...> wrote: Hello, My name is Roberto, Im new with all the stuff of Cx_Oracle. I'm working with Python 2.7 S.O. Windows Server 2003 Well, my problem is that when I'm doing a query to the database i have a column with a big float number but when I print my object I see that my numbers are rounded , what can I do ? I need the number with no rounding , please help me I'm new with this stuff. ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ cx-oracle-users mailing list cx-...@li... https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |
From: Paul M. <p.f...@gm...> - 2011-01-18 20:12:56
|
On 18 January 2011 19:54, Roberto Badillo Ibarra <bet...@ho...> wrote: > Sorry, i forget to tell you that on Python I'm just Printing the Object, So > I know that the problem is not on Python. There may be no problem at all (other than normal float rounding, which I suspect you're not aware of). See http://docs.python.org/tutorial/floatingpoint.html >python Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print 99345999999.9999 99346000000.0 >>> You might want to read up on Python's Decimal type (http://docs.python.org/library/decimal.html) and its use in cx_Oracle (see, for example, http://www.oracle.com/technetwork/articles/tuininga-cx-oracle-084866.html). Paul. |
From: Roberto B. I. <bet...@ho...> - 2011-01-18 20:46:25
|
Hey Paul Thanks a lot, it works Best Regars, Roberto Badillo > Date: Tue, 18 Jan 2011 20:12:48 +0000 > From: p.f...@gm... > To: cx-...@li... > Subject: Re: [cx-oracle-users] Cx_Oracle - Rounding Problem > > On 18 January 2011 19:54, Roberto Badillo Ibarra <bet...@ho...> wrote: > > Sorry, i forget to tell you that on Python I'm just Printing the Object, So > > I know that the problem is not on Python. > > There may be no problem at all (other than normal float rounding, > which I suspect you're not aware of). See > http://docs.python.org/tutorial/floatingpoint.html > > >python > Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> print 99345999999.9999 > 99346000000.0 > >>> > > You might want to read up on Python's Decimal type > (http://docs.python.org/library/decimal.html) and its use in cx_Oracle > (see, for example, > http://www.oracle.com/technetwork/articles/tuininga-cx-oracle-084866.html). > > Paul. > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |