Hi, a have a problem with float data type

i enter this code

create table #a(f float, d double)    
insert into #a values(20350.35, 20350.35)    
select * from #a

I see a different result in column f and d

f                d
20350.349609375 20350.35

i use SQL Anywhere 12. in early versions, such as ASA 8 was float_as_double option, that can solve this problem

is it bug?

asked 06 Jun '12, 01:13

Sergey's gravatar image

Sergey
6113
accept rate: 0%


It is by design - cf. the v11.0.0 "SQL Anywhere deprecated and discontinued features" docs - to cite:

float_as_double

In SQL Anywhere, the FLOAT keyword never behaves like Adaptive Server Enterprise's FLOAT keyword when a precision is not specified. SQL Anywhere does not treat FLOAT values the same as DOUBLE values.

For Open Client and jConnect connections, this behavior is different from the default behavior in previous releases.

When unloading or connecting to older databases with materialized views, the setting of this option is ignored.

Without that option, a FLOAT without precision is equivalent to the REAL data type and requires 4 bytes of storage, whereas a DOUBLE requires 8 bytes.

So I guess you ought to bring the datatypes into line (or use FLOAT with an explicit precision, such as FLOAT(53) - that should be identical to DOUBLE).

permanent link

answered 06 Jun '12, 04:11

Volker%20Barth's gravatar image

Volker Barth
31.5k321462677
accept rate: 32%

edited 06 Jun '12, 04:24

i read about that, but unfortunately I do not have access to source code and I can not change table definition. it is temporary table, that creates inside program ((

(06 Jun '12, 04:22) Sergey
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×36
×25

question asked: 06 Jun '12, 01:13

question was seen: 13,809 times

last updated: 06 Jun '12, 04:24