Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes SQL Server Floating Point Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Server Floating Point" Watch "SQL Server Floating Point" New topic
Author

SQL Server Floating Point

Matt Cannata
Greenhorn

Joined: Mar 23, 2001
Posts: 23
Hello everyone,
I am currently working which involves an ecommerce system. The database is MS SQL server 2000 and I am using the MS provided driver. The application runs on Orion Application Server.
I have a container managed OrderLine entity. I've tried the following primary keys for this entity:
Float orderNumber
Float lineNumber
and
BigDecimal orderNumber
BigDecimal lineNumber
In the DB schema, these are defined as type float. The DB supports the iMIS enterprise management system, so I can't change it (though I'd like to.) I'm trying to insert floating point values into the lineNumber field. Before the insert takes place, my program logs the proper values (1.01, 1.02, 1.03... .)
However, in the database the values end up distorted: (1.00999999046326, 1.01999998092651,
1.02999997138977 ... .) This occurs whether I define the bean with Float fields or BigDecimal fields.
Has anyone else encountered this problem? Is there a solution other than changing the schema to use decimal instead of float?
Any help appreciated,
Matt
 
 
subject: SQL Server Floating Point
 
Similar Threads
Use of Torque for dynamic data?
hi urgent
EJB create not using default value for not null column
Loss of precision worry when using Math.pow()
About Entity Bean with Struts