Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Query example:

select 1 as TAG,
       null as PARENT,
       '0' as "key", 7.27 as "value"
for json explicit



As a result, value should be as in the original 7.27, the format of the field is numeric (12, 5)


I'll be grateful, cast, round, truncnum doesn't help

asked 21 Nov '21, 15:46

Aleksandr%20Kushnirov's gravatar image

Aleksandr Ku...
accept rate: 0%

edited 21 Nov '21, 15:50

JSON numbers are either integer or double-precision floating point. Values like 7.27 cannot be expressed exactly as a floating point number. One option is to process these values as strings.

permanent link

answered 21 Nov '21, 23:07

Chris%20Keating's gravatar image

Chris Keating
accept rate: 31%

I agree when the string value is - works correctly. But then you have to convert to floating point number when building in Google Charts. And this is extra time. Thank you for your answer, I will try

(22 Nov '21, 02:37) Aleksandr Ku...
Replies hidden

The problem is that at the end of the day, 2.7 cannot be accurately stored in base2 as a real number (just like 1/3 can't be exactly converted to base10) - you will always being dealing with some sort of approximation. Floating point numbers are a computer thing not a mathematical thing!

I think decimal datatypes (when available) are stored as integer values and the appropriate offset then applied.

(22 Nov '21, 05:57) Justin Willey
Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 21 Nov '21, 15:46

question was seen: 680 times

last updated: 22 Nov '21, 05:57