round away from zero
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
I've been commissioned to write a function to round away from zeroI wish it were the same as round oracle
round(n , integer )
http://www.di.unipi.it/~ghelli/didattica/bdldoc/B19306_01/server.102/b14200/functions135.htm
with the following exceptions are used if there is no value for the second parameter (integer) default value 2because it's usually for pennies
the other exception is that it rounds of 0 round_away_from_zero (2.351) = 2.36 and round_away_from_zero (2.32,1) = 2.4
I'm close, but didn't quite.
create or replace function round_away_from_zero (v_n number, v_integer pls_integer default 2) return number as
begin
case mod(v_n,.1*(v_integer - 1)) when 0 then
return trunc(v_n,v_integer);
else
return trunc(v_n,v_integer)+ power(.1,v_integer);
end case;
end;
Here's my current incorrect resultswith t as ( select 1.231 nbr from dual union
select 1.101 from dual union
select 1.600 from dual union
select 1.423 from dual union
select .30 from dual union
select .9 from dual union
select 1.0001 from dual union
select 10 from dual
)
select nbr, round_away_from_zero(nbr,0), round_away_from_zero(nbr,1), round_away_from_zero(nbr,2)
from t;
NBR ROUND_AWAY_FROM_ZERO(NBR,0) ROUND_AWAY_FROM_ZERO(NBR,1) ROUND_AWAY_FROM_ZERO(NBR,2)
0.3 0 0.4 0.3
0.9 0 1 0.9
1.0001 2 1.1 1.01
1.101 2 1.2 1.11
1.231 2 1.3 1.24
1.423 2 1.5 1.43
1.6 1 1.7 1.6
10 10 10.1 10
Here is my expected resultsNBR ROUND_AWAY_FROM_ZERO(NBR,0) ROUND_AWAY_FROM_ZERO(NBR,1) ROUND_AWAY_FROM_ZERO(NBR,2)
0.3 1 0.3 0.3
0.9 1 0.9 0.9
1.0001 2 1.1 1.01
1.101 2 1.2 1.11
1.231 2 1.3 1.24
1.423 2 1.5 1.43
1.6 2 1.7 1.6
10 10 10 10
Ah--could help if that was not in your test case (which was very handy btw)!
Just change the function to test a negative signal, if so, multiply by-1, appeal of ceiling and multiply and then back to the negative. that should do the trick.
PS the suggestion of Frank below to use the SIGN and the ABS is much more elegant, don't know how I didn't have it after the bad things I used to do with SIGN and DECODE pre CASE days statement!
Published by: Carlovski on November 29, 2010 18:51
Tags: Database
Similar Questions
-
Do I understand the instructions re using HomeKit away from home? I read the instructions that I have to have an Apple TV, or I can't use HomeKit away from home. What is the correct understanding? Thank you!
It depends on the product, but yes in some cases they use an Apple TV as a hub so that you can access the service by far.
-
I ran scans using Norton Security Suite and Microsoft Safety Scanner and cannot get rid of the malware Taskeng.exe. My guess is that because it shares the same name as a legitimate file, the antivirus software does not recognize it as a malware. Also, I went online to get suggestions and tried to open the computer in Mode safe to look for a second file with the same name, but it does not appear. The malware Taskeng.exe turn away from my Firefox at Yahoo homepage which slows down Firefox when opening and it slows the opening of other sites as well. Suggestions?
Favorite and use this.
Mozilla search reset {web link}
This module is very simple: when installing, it backs up
and then resets your search and home page preferences
at their default values and then to uninstall. This
affects the search bar, search bar URL, and home
page.FIRST BUT cela;
Sometimes a problem with Firefox can be a result of malware installed on your computer, you may not be aware of.
You can try these free programs to search for malicious software that work with your existing anti-virus software:
- Microsoft safety scanner
- MalwareBytes' Anti-Malware
- Anti-Rootkit utility - TDSSKiller
- AdwCleaner (for more information, see this other AdwCleaner download page)
- Hitman Pro
- ESET Online Scanner
Microsoft Security Essentials is a good permanent antivirus for Windows 7/Vista/XP, if you do not already have one.
More information can be found in the article troubleshooting Firefox problems caused by malware .
This solve your problems? Please report to us!
-
Sites of anime I've been visiting years now the following happened when you connect to AnimeFreak.tv or Justdubs.net - who are normal:
During a second instance of Firefox opens without my permission and without any warning.
It appears on the wall announcement. Sometimes it's a regular advertising, and it was sometimes adult.
I'd appreciate it greatly in the next update of firefox something can be installed that brings a pop up that allows you to block it if you choose or make sure there is a checkbox additional security as blocker called blocker of the Forum or something that would block such action that web pages. This security hole is a step away from a Web site that infects a computer with a virus. This seems to be something of a new technique of advertising as I only noticed it happening last week. I took a screenshot of one of these cases. This is an advertisement for Gamemazing.com. I don't see a way to include an attachment otherwise, I will send the picture as well.
Help your navigation software to become safer then Microsoft IE.
Those are pop-ups. They can be sent across the net from a site, you are
now, or even a program on your system. Add them to your Firefox.Adblock more {web link}
Blocks annoying video ads on YouTube, Facebook ads, banners
and much more. Adblock Plus blocks all the annoying ads, and
supports Web sites by blocking is not discrete (configurable) default ads.Pop-up Addon Adblock more {web link}
Adblock Plus pop-up Addon - extends the functionality of blocking of the
Adblock Plus for those annoying windows pop up that opens on the mouse
clicks and other actions of the user. -
I a s 6 more and when using the phone, if my face touches the screen it clicks on the logout button and the phone hangs up the call. Is it possible to prevent this without holding the phone away from my face when calling?
iPhones have a proximity sensor which is supposed to automatically turn off the screen when you hold it in your face. If this is not the case you can take the phone and have it checked.
-
should I unplug iMac so that away from home for a period of time
I'll be away from home for 6 weeks, we have power periodic interruptions where I is direct, he bet to unplug the iMac and airport Time Capsule at the moment that I'm missing?
As long as the computer is turned off, it is not really necessary to unplug. IF you live in one are frequent interruptions with electricity then I would say strongly to get a UPS to protect your devices.
-
the wifi does not work on my iPhone when I'm away from the router in my room, but it's not too far, it's like a couple of inches away from the living room and it does not work for some reason...
First restart the router - remove all power for 15 to 30 seconds.
If that is fixed not try to change channels on the router using the router configuration panel.
On the phone go to settings/general/reset - Reset network settings if any of the above doesn't help. It will be reentering your WiFi password.
-
I'm trying to slow down the speed of text scrolling in the distance away from text generator. Is it possible to make the text scrolls more slow?
Stretch it to extend it.
-
wanted m6 1105 dx: money return happens away from black screen border
When I closed my laptop today, the Silverback came away from black screen edge on the lower left corner of tne hinge.
Hi @amhirsch,
Welcome to the HP Forum! This is a great site to find information, tips and suggestions. You have the most rewarding experience please consult the HP Guide's Forums. First time here? Learn how to publish and more.
I understand that the silver film is separates the black screen frame in the lower left corner of the hinge on your laptop Envy. As it is a hardware issue, please contact HP support for service options. Please contact HP to Contact HP Support assistance.
Please let me know the results.
To express the gratitude of my post please click on the "Thumbs Up Icon'." " If my post solves the problem you are experiencing, please click'accept as Solution' to help others find what worked for you!
-
start two game clients 'same game' on my desktop, but when I switch between games, the title on one of the windows changes and freeze the game inplace until I click on it... Q is there away from keep two active windows? Use Sandboxie to run the second client of the game...
Hello
(a) what game are you trying to play?
(b) is an online game or software installed on your computer?You have contacted the support of Sandboxie, to determine if the program is able to provide this functionality.
To do this, click on the following link: Help of Sandboxie
If it's an online game, you can also use the new session under file in Internet Explorer to connect with two different credentials.Thank you, and in what concerns:
Swati Keni-Microsoft Support -
HP TouchSmart Tablet: unable to connect to wifi when away from home
Just bought a HP TouchSmart laptop to use when away from home. I just took in Santa Fe and could not get a wifi connection. I could get one on my smartphone, but not the laptop. Rookie here... Please dumb down of recommendations!
taosdon wrote:
Just to remind you, I'm not computer savy. I always thought that data on my phone meant that I was hooked up to wifi. I have to pay for some sort of service to use my laptop other than at home? I have wifi at home. Thank you!
None of the cell if the installer can use wifi connections or a cell phone. Mobile home mine is configured to use my wifi and when I'm out of reach it switches to the use of the cell phone Tower. It's for the smart phone not your regular clamshell phone types. So the best test is to take your laptop and go to a public wifi and see if you can connect to the wifi and use which would be another way to diagnosis if the problem is the Wi - Fi connection or something else.
-
Can I print a CD instead of a printer information when I'm away from my printer?
Can I print a CD instead of a printer information when I'm away from my printer?
Can I print a CD instead of a printer information when I'm away from my printer?
You can use PDF reDirect to print files and later print these files on your printer.
-
I use Outlook as my main e-mail client, but I have access to my email address when I'm away from my computer with Hot Mail.
When I do all of my incoming emails go to the "Deleted" folder instead of the "Inbox".
Please notify.
Bob BurnsAfter all the Hotmail issues in the appropriate forum found here:
http://windowslivehelp.com/ -
How do I enter usb storage away from home?
I would like to access my usb storage away from home since Ios and android devices
I googled and have not been able to find info.
Thanks adavance.
In addition, you can also see these articles for more info on the EA4500 router.
Linksys router Smart Wi - Fi, EA4500 frequently asked questions
Get to know the router Linksys Smart Wi - Fi, EA4500
How manually update the firmware on the Linksys WiFi Smart router
-
our laptop has two users. A user can log in and use internet via internet explorer or firefox. the other uses when connecting. Internet Explore starts and displays a page web teling them in locked PC requires £100 to unlock, this page covers the entire screen and there is no way to get away from her. You must change user to operate using laptop computer
* Original title - performance and security in Internet Explorer *.
Hi Anthony,.Your computer is probably infected by a virus. Try following the steps in this virus/malware removal guide: http://www.selectrealsecurity.com/malware-removal-guideIt contains instructions which will remove most malware infections. If you have any questions, just ask me. I hope this helps you.Brian
Maybe you are looking for
-
Firefox is compatible with wince6
HelloI installed a Radio S100 Roadnav system in my car. There the Wince 6.0 operating system. He has touchscreen and Opera 5.1 for surfing the internet. I'm not at all happy with Opera 5.1 and don't want to use IE.Is there a version of Firefox that i
-
After RAM upgrade kernel panic
IMac 21.5 mid 2010 2 x Kingston 8 GB RAM Anonymous UUID: 48A5979F-AE09-EDC6-A083-98F4ABD9B696 Mon May 23 14:56:23 2016 Panic report *. panic (cpu 1 0xffffff8015fb363a appellant): ' link element invalid queue for 0xffffff802a8df540: 0xffffff803673b3d0
-
Location does not show in the Photos showing each year
In my app Photos a year, it will also show the summary of the situation (like my photo in 2014) But in my photos from 2015, it shows nothing about location (see image2). But when I Zoom, I see all location information (see photo 3) Anyone know how to
-
KLV-40ex430 HDMI - required Firmware?
My HDMI with DSTV does not work - I think it's a problem of handshake, but if I use the HDMI on other he sees work 100% I recon I need to upgrade the firmware - I have the current version is of 1,110, but I can't find a version update on the web?
-
Yoga, 13 screens darkens when unplugged
I had only my Yoga for a few days and love it. I noticed that when I unplug it the screen darkens. I have normal, predictable courthouse or a sign of a problem? Thank you