Question on the rounding of decimal numbers

Hi, I have a requirement that says that if I have a decimal number, say,

16.15446

I would like to see as a 16.16

The values that I have provided with will always be 5 decimal places.

If I am provided with 16.15552, I should display as 16.16 too.

of course, I tried:
select round(16.15446,2) as test_value from dual

TEST_VALUE
----------
     16.15

1 row selected.
But obviously, this is not what I expected.

Any suggestions?
SQL> select round(round(round(16.15446,4),3),2) as test_value from dual;

TEST_VALUE
----------
     16.16

SQL> 

Published by: W Nicloei November 24, 2008 18:52

Tags: Database

Similar Questions

  • Question of the ROUND function

    Hello

    No idea if this is right?

    Select (1100.55*(1/30)), ROUND ((1100.55*(1/30)), 2) to double;

    should 36.685 be 36,69 rounding?

    Thank you

    Vignesh

    Think about it:

    Select

    Round(1100.55*1/30,2)

    , round (1100.55*(1/30), 2).

    of the double

    ROUND(1100.55*1/30,2),ROUND(1100.55*(1/30),2)

    «36,69 ', ' 36,68»

    1/30 is something on 0,3333333333333333333...

    So if you force to calculate 1/30 first your result would be something about 36 684...

    If round(, 2) will end at 36,68.

    But 1100.55 can be divided by 3 without rest.

    But 1100.55 can be divided by 30 so that the result is finite (infinite not like 0.33333...) can be kept full by the number of data type.

    So, if the calculation order is 1100.55 divided by 1, then didved by 30, this would translate exactly in 36 685.

    It seems to me the use of parentheses introduced some binary float during the calculation, because it can be assumed with regard to landfills:

    Select

    dump(1100.55*1/30)

    dump (1100.55*(1/30))

    of the double

    DUMP(1100.55*1/30),DUMP(1100.55*(1/30))

    ' Type = 2 Len = 4: 193,37,69,51 Typ ',' 2 Len = 21 =: 193,37,69,50,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,97 ".

    Therefore, the result is a bit small (in this case, could be another average round in other cases) and turn therefore not lead to the expected result.

    Without the parentheses all operands are considered as numbers and so round gives the desired result.

    The reason may lie in the fact that oracle doesn't really change the bytes when converting from float to the number:

    Select

    dump (0.3)

    truck (cast (0.3f as number))

    of the double

    DUMP (0.3), DUMP (CAST(0.3FASNUMBER))

    ' Type = 2 Len = 2: 192,31 Typ ',' = 2 Len = 6: 192,31,1,1,2,21 ".

    Post edited by: chris227 corrected and extended

    Post edited by: chris227

  • Result of the calculation were separated to the whole and decimal, number not rounding correctly

    I have 2 fields as a result of sharing: the whole and decimal number (1 decimal place). I Math.floor the result to get the whole number and everything is fine until I hit a case where the result is 92,97.

    This should give "93" in the whole of the field and '0' in the decimal field, instead it gives me '92' and '10' (even though I'm only hosting 1 character in the field).

    How can I get the '93' and '0' in the following code?

    fieldLVEDV = this.getField("LVEDV").value;

    fieldBSA = this.getField("BSA").value;

    If (fieldLVEDV! = "" & & fieldBSA! = "") {}

    totalLVEDV = this.getField("LVEDV").value + ((this.getField("LVEDVDec").value)/10);

    calculation = (totalLVEDV / fieldBSA);

    calculationDecimal = calculation;

    partWhole = Math.floor (calculation);

    if(partWhole <0) {partWhole =' ' ;}}

    this.getField("Index").value = partWhole;

    this.getField("IndexDecimal").value = Math.round (10 *(calculationDecimal-partWhole));

    {If (this.getField("IndexDecimal").value = '10')

    {

    this.getField("Index").value = partWhole + 1;

    this.getField("IndexDecimal").value = "0".

    }}

    } else {}

    this.getField("Index").value = "";

    this.getField("IndexDecimal").value = "";

    }

    I thought I'd add the blue part would do the job, but obviously it did not work.

    Ah, your problem is that you do not use the correct comparison operator. To check if two values are equal, the operator is "==" not not "=". Using "=", you assign the value 10 to the field which you then pass in 0 a few lines down. Use 'is' and things should work correctly.

  • Align decimal numbers for the track list

    Hello, you showed me how do it long ago and have forgotten since. I have a Tracklisting of a paragraph as follows:

    1.

    2.

    3.

    4.

    5.

    6.

    7.

    8.

    9.

    10.

    11.

    I followed the tabs tut in the CC tut who says line right to the top of the box of the tab with the text block, click align decimal numbers and click where you want to go, I get the orange arrow, but nothing aligns. The UTU uses a table for example, is the only way it will work?

    Kind regards.

    If you do just a numbered list, you only need to use tabs to align on the decimal point. Simply insert a fixed space called a figure space.

    Make sure your numbers are of equal width. Since the character or control panel menu > OpenType, make sure Tabular Lining is set for numbers:

    Then in front of 1, 2, etc. Insert a space figure (Type > insert a space > Figure space). White space is the width of any character. You can use several spaces figure if you were with a very large number.

  • ORA-01722: invalid number - when the last column has numbers that have a decimal separator

    Here are examples of data-

    FRT, 1.64, VAT, 23,36

    FRT, 1.64, VAT, 23,36

    When I try to convert 1.64 to_number everything is good, but when I do the same thing with 23,36 I get the following error

    ORA-29913: error in executing ODCIEXTTABLEFETCH legend

    ORA-01722: invalid number

    ORA-06512: at "SYS." ORACLE_LOADER', line 52

    I tried this query example

    Select to_number (CONSIGNMENT_NET_VALUE) as Col1 of DUMP_EXT

    Select to_number (CONSIGNMENT_NET_VALUE, '9999999999D' 99999', NLS_NUMERIC_CHARACTERS = ",". ") as Col1 DUMP_EXT-> 268906.1

    make the same mistake - any help greatly appreciated.

    T.

    Srini

    Try using:

    RECORDS DELIMITED BY newline

    Instead of:

    RECORDS DELIMITED BY '\n'


    on your table to create, in addition to just help to_number or to_number return with ' NLS_NUMERIC_CHARACTERS = ".," ' in your query, in the period before the comma as decimal separator comes before the grouping separator.

    What is probably happening is that your return to the line of the system data come from different East of your new line on the system that you load in.  You may need to experiment and

    Select dump (consignment_net_value) in the dump_ext;

    to determine what additional invisible characters, such as Chr (10) and Chr (13) can be added at the end of the number that you have to cut, so just using line feed does not work.  This is why it only happens with the numbers at the end of the line.

    Post edited by: BarbaraBoehmer

  • question on the numbers of the UUID on data warehouses

    I have a couple of hosts in different groups. Clusters share some data warehouses, but have a few stores unique data that is clean. This means that some common data stores have different UUID across clusters. What happens if you cold migrate or vmotion virtual machine through the clusters. different UUID numbers cause problems?

    Article KB (1006052) said about this problem and according to the instructions this vmotion will fail and he described in detail the resolutions.

    Adding a host by these four different methods produced four different UUID:
    • host name
    • nomhote.nomdomaine
    • IP.address.of.host
    • HOST vs hostname name

    Hope this gives advice.

  • Round a decimal number

    I have a domain where the final answer is in decimal form and the client wants the final answer for the employee to be an integer, but he rounded upward, no matter what the decimal answer is. Is it possible to do?

    The script could be something like:

    Custom calculation script

    (function () {}

    Get the field values as numbers

    var v1 = + getField("Average_of_scores").value;

    var v2 = + getField("Text_4").value;

    Perform the calculation, round down to the nearest integer, and set the value of this field

    Event.Value = Math.ceil (v1 * v2);

    })();

    For more information about Math.ceil method, see: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil

  • Decimal numbers PHP/MySQL

    Hello

    I'm working on a real estate site. Most monthly apartment rental rates are round numbers like $950, however a few have odd prices like $1070,76 (where the need for decimal data type in MySQL).

    On the page where are all the apartment ads, what I want to do is to remove the decimal point and zeroes if the number is round because all zeros are distracting (and useless). For example:

    I have this code snippet:
    If ($r-> maxRent == 0) {}
    $price = ' requested rent $';
    $price. = $r-> minRent;
    $price. = "monthly";
    } else {}
    $price = ' requested rent $';
    $price. = $r-> minRent;
    $price. = '-';
    $price. = $r-> maxRent;
    $price. = "monthly";
    }
    Which shows this:
    Ask the rent 810, 00-950, 00 per month
    1070.76 rental request - $1200.00 per month
    Asking rent $1335,00 per month

    But I want things to be displayed like this:
    Rental $810-950 per month
    1070.76 rental request-$1200 per month
    Rental $1335 per month

    What I have to do it work with regular expressions (Voodoo!) or is there another way? I am currently in a situation where I have to use outdated versions instead of all (PHP 4.1.2 / MySQL 3.23) if that makes a difference in this case.

    I looked through my books and I tried Googling & forums for an answer to the search, but I'm not sure of exactly what I should look for, so I won't have a bit of luck. Any help would be greatly appreicated.

    Kind regards
    Bev

    bsoliman wrote:
    > But I want things to be displayed like this:
    > Asking rent $810-950 per month
    > Asking for rent 1070.76-$1200 per month
    > Asking for rent $1335 per month

    In fact, le.76 seems to me more confused than la.00. I'd do it
    Just use round() to give a round for all rents figure. However, if
    you want to do it your way, add this function to your script:

    function checkEven ($val) {}
    return preg_match ("/ \d+\.00 /', $val")? number_format ($val, 0):
    number_format ($val, 2);
    }

    Then change your code to do this:

    If ($r-> maxRent == 0) {}
    $price = ' requested rent $';
    $price. = checkEven ($r-> minRent);
    $price. = "monthly";
    } else {}
    $price = ' requested rent $';
    $price. = checkEven ($r-> minRent);
    $price. = '-';
    $price. = checkEven ($r-> maxRent);
    $price. = "monthly";
    }

    --
    Adobe Community Expert David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • What is the use of the keyboard of phone numbering alphabet

    What is the use of the keyboard of phone numbering alphabet

    I could be misunderstanding your question, but if you mean the letters below the numbers on the keyboard of the phone (for example the ' ABC' below the 2), use only one of them is for companies of advertising with easier to remember numbers. For example, Apple Announces the number (800) MY-APPLE which is composed as (800) 692-7753 words are easier to remember and the numbers on the keyboard allow to translate the letters to numbers that you dial.

  • The locale-specific decimal separator in Fmt?

    Is there a way to get the floating point numbers using the locale-specific decimal separator in the Fmt() function?

    It seems that SetSystemAttribute will only change the separator of UI elements, as described in this thread.  Call setlocale (LC_ALL, "") doesn't seem to work either.

    Is this possible?

    Thanks for the reply.  I ended up just do a search / replace and permutation of every instance of Fmt() with sprintf_s(), which DOES pay attention to the setlocale() function.

  • ADDITION TO THE SEARCH REPORT PAGE NUMBERS

    I read the posts on the insertion of the page numbers with Vista on Word.  I need to be white, but the next three pages to have Roman numerals, the title page. The text of the book will be numbered beginning with 1. Please help, the format of this document must be correct. Please provide guidance in terms of. layman, the paper is ready to be sent to a higher level with the exception of page numbers... Thank you.

    Hey DDWILKES,

    Thank you for visiting the website of Microsoft Windows Vista Community.

    The question you have posted is related to Microsoft Office, and would be better suited to the Office Discussion groups.

    Please visit the link below to find a community that will provide the support you want.

    http://www.Microsoft.com/Office/Community/en-us/FlyoutOverview.mspx

    I hope that the information above helps you.

    Kind regards

    Manasa P-Microsoft Support.

  • Question about the strength of password

    (do not ask questions about the recovery of the password, so please do not report this thread)

    OK, I heard that the virus can change the password on a computer.

    But if you have a password very complicated (for example, one with a lot of numbers and other things), it will be more difficult/less likely for the virus to be able to change your password?

    Yes.  A strong password is, it is more difficult to crack.  For more information, see create strong passwords on the Microsoft online safety site. Boulder computer Maven
    Most Microsoft Valuable Professional

  • suspicious customer relationship questions on the computer's performance in windows 7

    I received calls for two days of GPS Customer Relations, division of Microsoft Windows ask me questions about the performance of my computer. Is it a scam?

    Wednesday, September 19, 2012 17:12:51 + 0000, Charlene BZ wrote:

    I received calls for two days of GPS Customer Relations, division of Microsoft Windows ask me questions about the performance of my computer. Is it a scam?

    Yes!

    It's a scam and with various names and phone numbers, is
    very frequent lately.

    In addition to their money get on your part to do anything of any value,
    If you leave them in your computer, which knows what losses they did are
    where confidential information they stole.

    So if you have done so, I highly recommend that you do both of the following
    immediately:

    1 do a clean reinstall of Windows.
    2. change all of your passwords, especially banks or other
    financial sites.
    Ken Blake, Microsoft MVP

  • Regex to allow only integer and decimal numbers.

    Hi all

    I need a regex to allow only integers and decimal numbers.

    Examples:

    100 licences

    100.00 - Unauthorized

    100 - unauthorized

    100.11.22 - unauthorized

    all characters other than numbers - unauthorized

    I used the regular expression - ^ [0-9] +. ? [0-9] * $- but its allowing the "100" also.

    Can someone help me solve this problem.

    Your timely assistance is greatly appreciated.

    Thanks in advance.

    Hello

    inDiscover wrote:

    Hi all

    I need a regex to allow only integers and decimal numbers.

    Examples:

    100 licences

    100.00 - Unauthorized

    100 - unauthorized

    100.11.22 - unauthorized

    all characters other than numbers - unauthorized

    I used the regular expression - ^ [0-9] +. ? [0-9] * $- but its allowing the "100" also.

    Can someone help me solve this problem.

    Your timely assistance is greatly appreciated.

    Thanks in advance.

    Use

    ^[0-9]+(\.[ 0-9] +) ? $

    to make the decimal point and the following figures (of which there must be at least 1), as a unit, as an option.

  • Bug of STROKE Weird Illustrator containing decimal numbers

    Hello

    I m having this really weird in Illustrator bug when I try to change the size of the stroke to something with decimal numbers. When I have a call 1 pt or pt 2 it works as expected, but when I change it to something like 1.6 pt, the trait is uneven on the way. Some lines are thicker than others, and it's very weird.

    Can someone point me in the right direction? See my 30 sec video-screen for an overview of the bug.

    Bildschirmfoto 2015-06-12 um 09.02.29.pngBildschirmfoto 2015-06-12 um 09.02.16.pngBildschirmfoto 2015-06-12 um 09.02.03.png

    Thanks for your help in advance!

    sure it is an alignment at pixel grid.

    Select the object and check the transform palette. 'show options' in the menu if the option is not visible.

Maybe you are looking for