Sitemap

Amicuk Programming Answers

Round float to 2 decimal place in the table

2015-10-11   Views:3

Advertisement

Hi, One field in a table in my DB has float datatype. I insert some data into this table. The value read from a textbox I input as 0.02 for example. after insertion, I select the table and the field of the table shows the number as 0.0199999995529652

Hi,
One field in a table in my DB has float datatype.
I insert some data into this table. The value read from a textbox I input as 0.02 for example. after insertion, I select the table and the field of the table shows the number as 0.0199999995529652
Where did I do a wrong thing? how can I make it exactly as 0.02 in the table?
Thanks.

The replay answer
Advertisement
Hi there
Float data types have known problems with precision, see
here
Since FLOAT and REAL are approximate numbers, you can run into all kinds of presentation / storage issues if you use them inadvertently. 
They have their place, and if you are using scientific data that requires the properties of floating point numbers, th they are the right choice.  But in most cases, I think this is another evolutionary thing that happens accidentally when you upsize
from Access.  You are much better off using DECIMAL or NUMERIC (which are functionally equivalent) unless you really know that you should be using FLOAT.
You should consider changing the datatype to decimal or numeric if you need it to be more precise.

Go to See the other 3 answers

Round float to 2 decimal place in the table

Category:DefaultRelease time:2015-10-11Views:130

Hi, One field in a table in my DB has float datatype. I insert some data into this table. The value read from a textbox I input as 0.02 for example. after insertion, I select the table and the field of the table shows the number as 0.0199999995529652[More]

Round 3 Digits before decimal in Chart and Table

Category:DefaultRelease time:-0001-11-30Views:130

Hi Guys, Do you know where I can find the option/property in the chart and table to round 3 digits before decimal. Refer snapshot below: For example, in below case Y axis original value is 40,000, 80,000 etc. but it should show on the graph and table[More]

Rounding off float to 2 decimal places and returning the float

Category:DefaultRelease time:-0001-11-30Views:130

I tried doing bigdecimal but it doesnt work. : BigDecimal bd = new BigDecimal(5 * 0.0394);           retval = bd.floatValue();           System.out.printf(" th %f\n",retval); I see 0.197000. I know that there are 6 places since I didnt do %.2f.[More]

Price per unit is getting round off to two decimal places.

Category:DefaultRelease time:-0001-11-30Views:130

Hi Gurus, In the Billing output, the Price per unit is getting round off to two decimal places. How can we avoid this or allow 4 decimal places for such cases. In the same pricing procedure, we have two pricing condition types PR02 and ZR01. When PR0[More]

Is it possible to convert a float to two decimal places

Category:DefaultRelease time:-0001-11-30Views:130

Can anyone help me to convert a float to two decimal places float f=16; System.out.println(f); It will print 16.0 But I want to get printed as 16.00"convert" no, as no conversion is needed, obviously. Format the output, yes. Read the API for Str[More]

How do I round calculations to two decimal places (form-wide)

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I've created an order form where customers input the quantity of product they want to order and the form outputs the total due (including shipping and sales tax). Depending on user input, the resulting total sometimes contains more than two decim[More]

Round off to two decimal places

Category:DefaultRelease time:-0001-11-30Views:130

hi i have a filed in it values are there i want to round off to two decimal places which is the function module for it please suggest regards AroraHi Nishant Arora, Please check this code. DATA: N1 TYPE P DECIMALS 4 VALUE '0.0565',            N2 TYPE[More]

Rounding off a float to two decimal places

Category:DefaultRelease time:-0001-11-30Views:130

I want to make a function where I shall pass a float and and integer. The float shall have to be rounded off to a value in the integer. Can anyone please suggest how to round off a float. E.g.: if the float is 12.56890 and I want to round it off to 2[More]

How to convert a number to FLOAT with 9 decimal values.

Category:DefaultRelease time:2015-10-11Views:130

Hi all, I need to convert a number like '10.02' to a floating point number with 9 decimal values like '10.022111221'. I think that the right function is TO_BINARY_FLOAT, but how can I obtain 9 decimal values? If I use the following syntax: select TO_[More]

Cutting a float to 3 decimal places

Category:DefaultRelease time:-0001-11-30Views:130

Hello, i have a float value with a different amount of decimal places. The Problem i have is, that i need to cut this places down to 3 decimal places (eg. 12.345678 => 12.345). If this halps if i can also use Float instead of float. But it would be f[More]

Rounding float value to nearest 0.05

Category:DefaultRelease time:-0001-11-30Views:130

Hi, can you tell me if there is a convenient way to round off a float ot double to nearest 0.05. Example: 18.93 -->18.95 and 18.92 --> 18.90Yes. Multiply it by 20. Round to the nearest integer. Divide by 20.Read other 3 answers[More]

Hot
Hi, I am new in FLex , Is there any can help me in image processing . Can some one tell me about How to change image through flex and action script ? e.g sharpness, grayscale, resize, save, rgb, brightness, crop etc............ Thanks in advance Rega [More]
Hi have 3 sun ray 170 thin clients that used to work on an older sunfire v250, but now we have upgraded to a new IBM 3500 series running CentOS 5.4 64 bit. We are trying to get the thin 170s to work with the new 4.2 version of sun ray software. We ha [More]
Hi Experts, My user wants to know if SAP can generate a Trial Balance Report by G/L Accts, Cost Center and Profit Center. Please let me know the transaction codes. I also checked some like: F.01 (Financial Statements), or S_ALR_87012277, or S_ALR_870 [More]
Now i am using WAD 7.0 and would like to get sum of each column from a query. I have put a analyse_item_1 in the web template. Could someone tell me how i can get sum from each column? thanks!Hi, i have assigned the points to your answer. - Thanks fo [More]
The title pretty much says it all....Hi.  Thanks for the information.   I did follow your advice, but I do not have a Mail & Mail downloads file in my (my name) Library folder.  There is one in the Guest folder, but all it does when I click on it is [More]
Fairly new forms so bare with me. I am creating a form based on one table. This table has one column that is a nested table. table name: szrtime table columns: szrtime_code, szrtime_styp_list szrtime_styp_list is a table of varchar2(1). main block is [More]
Hello I'm writing a paper about floating point numbers in which I compare an IEEE-754 compatible language [c] with Java. I read that Java can do a conversion decimal->binary->decimal and retain the same value whereas c can't. I found several documen [More]
Hi, J2EE Server is not getting started, the exit code is -11113. When I tried to start J2EE Enginer Visual Administrator its giving below error. Unable to lookup connection default. https://SAPXI:8101/msgserver/text/logon returned empty list of conne [More]
Hi, I am trying to pre-fill the OLAP cache with data from a query so as to improve the performance of query views.  I have read several documents on the topic, such as “How to… Performance Tuning with the OLAP Cache” (http://www.sapadvisors.com/resou [More]
I would like to assign different actions to 1 image...ex. have different words on a graphic lead to their own respective pages. Do I need to break out the graphic and create a different layer/image for each word, or can i keep it as one image/layer a [More]