MOD() function - incorrect output

The following bit of SQL uses the mod() function to determine modulus 2 of two large numbers
13:37:20 SQL>set echo on
13:37:24 SQL>@mod_test
13:37:25 SQL>
13:37:25 SQL>
13:37:25 SQL>
13:37:25 SQL>select mod(power(2,127)-1,2) from dual
13:37:25 2 /
MOD(POWER(2,127)-1,2)
1
1 row selected.
13:37:25 SQL>
13:37:25 SQL>select mod(power(2,128)-1,2) from dual
13:37:25 2 /
MOD(POWER(2,128)-1,2)
-1
1 row selected.
13:37:25 SQL>
Notice that mod(power(2,128)-1,2) returns an incorrect answer, while the
answer for mod(power(2,127)-1,2) is correct.
Does someone here know why?
Is it a limit?
Or is it a bug?
Please supply an explanation and/or URL for your answer. :)

Must be due to the fact the scale for a NUMBER can range from -84 to 127, and Floating Point Number Limits are:
Value                         Binary-Float          Binary-Double
Maximum positive finite value 3.40282E+38F  1.79769313486231E+308
Minimum positive finite value 1.17549E-38F  2.22507485850720E-308

Similar Messages

  • Error "Terminal type 202: Incorrect output destination/message type TERM"

    Hi:
        We actually are using SRM v. 5, and we detected an intermiteng error in SM21, it says
       <b>Terminal type 202: Incorrect output destination/message type TERM</b>
       It is generated at Client 000 and relates to program BBP_BGRD_APPROVAL. The actual output of the log is described:
                   <b>Terminal type 202: Incorrect output destination/message type TERM
                   No Active Link Found in the Link Table                           
                   > Conversation ID: 39968053                                      
                   > CPI-C function: ?                                              
                   No Active Link Found in the Link Table                           
                   > Conversation ID: 39968053                                      
                   > CPI-C function: CMRCV                                          
                   Delete session 001 after error 004            </b>
           What we are worried about, is that the final error, relates to a user session end =(.
           We were looking for some information on SAP Notes and forums, but we didn't find any useful info.
           Does any one know what is this error about? We will appreciate any comments.
                        Thanks in advance, Abrahamdelgdaov

    Hi,
    This kind of error message usually arises if a program wants to send
    data to the partner program which will be identified via the
    conversation ID, but this conversation ID is not in the list of
    active RFC links.
    This always happens when one of the two partner programs finishes the
    conversation and informs the remaining partner program.
    Also included in this information is that the gateway already deletes
    the communication entry in the communcication table and conveys the
    message to the partner program.
    This partner program in turn accepts the message but still wants to
    send a receipt or something else to the program that is already finished
    Another send after you've received the close of the connection is not
    allowed.
    Therefore the messages you are seeing in the syslog are definitely ha
    rmless because even if the send would go through, the receiver is not
    able to receive the message.
    Check if there are any other network related errors in the system.
    Regards,
    Marcelo

  • How do I use the print function to output a numeric variable with a fixed amount of leading zeroes

    I need to create an output from a T-SQL query that picks a numeric variable and uses the print function to output with leading zeroes if it is less than three characters long when converted to string.  For example if the variable is 12 the output should
    be 012 and if the variable is 3 the output should be 003.
    Presently the syntax I am using is PRINT STR(@CLUSTER,3) .  But if @CLUSTER which is numeric is less than three characters I get spaces in front.
    Please help!

    >> I need to create an output from a T-SQL query .. <<
    NO! NO! In RDBMS, we have a presentation layer that handles displays. We do not ever do it in the database. This is fundamental. But more than that, the purpose of PRINT is for debugging in T-SQL and never for output.
    You are still writing 1960's COBOL or BASIC, but you want to to it in SQL.  You probably picked the wrong data type (a numeric that should be a string) and are trying to repair your design error.  
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Error "You cannot enter a partner function for output NEU"

    Hi Experts,
    I'm having these error "You cannot enter a partner function for output NEU" (message VN041) when I tried to assign a partner function (e.g OA)  in the conditions records for application "EV" (Purchase outline agreement). The system do not allow me to do this for any doc type (LP, LPA, MK, OA, etc). I'm using t-code NACE or MN08.
    I want to assign partner for key combination "Document Type". The conditions is already there but with no value, so I want to assign partner function "OA" or "VR".
    I already check all the configuration and looks fine. For example, define possible partner functions for output type "NEU" for application "EV" (Purc outline agree).
    Hope you can help me to find the problem.
    Thanks,
    Mairo.

    I have the error in NACE or using tcode MN08.
    As soon I executed those transaction the system shows the condition records created for varios Doc Type (e.g LP, LPA, MK, etc) but with no partner function assigned. For example:
    Doc. Type /  Name                     /             Funct  /   Partner     /            Medium  /  Date/time  /   Language
    LP        /       Scheduling Agreement     /  blank  / blank  /                                          2      /          3   /              EN
    LPA      /      Scheduling Agreement                              / blank    / blank   /                1        /       3         /        EN
    For example, I try to assign function "OA" for Doc. Type "LP", choose value from quickpick. Then when I press enter, the system give me the error "You cannot enter a partner function for output NEU", message no. VN041. Do not allow me to continue, so I have to leave this field blank, with no change.
    Thanks,

  • Subpartition with MOD Function in Oracle 11g

    Hi All,
    Can we create Subpartition based on MOD Function in Oracle 11g ?

    Hi!
    What are you refering with "MTS"? Anybody knows a term like this (except MultiThreaded Server).

  • Mod function in LabView's Configure Formula

    Hello, all.  Today is my first shot at using the Configure Formula feature in LabVIEW (7.1), and I'm not doing well at it.
    The kicker seems to be my (mis)understanding of the mod function.
    Here's the formula I have to work with:
    J=1+(((((C/100)%4)*5)+G)%7), where

    duplicate post, see: http://forums.ni.com/ni/board/message?board.id=170&message.id=161086
    LabVIEW Champion . Do more with less code and in less time .

  • Using the Safe Mode function on your PlayStation 3?

    i followed the steps it works fine then when i sign in within a afew seconds it cuts off and gets a red flashing light again i dont know what to do :/

     
    RabidWalker wrote:
    Using the Safe Mode function on your PlayStation 3?
    Safe Mode:
    The option to use Safe Mode on the PlayStation 3 was introduced if a problem occurs where it will no longer start up normally.
    To use this feature the console will need to have the System Software update 2.60 (or later).
    When to Use Safe Mode?
    When starting up the PlayStation 3, and the XMB menu no longer appears (you may see a wavy line on the background instead).
    When the PlayStation 3 is started up, nothing appears on screen.
    When the PlayStation 3 is started up and you encounter the following message ‘The Hard disk’s file system is corrupted and will be restored’. When selecting ‘OK’ the system restores and restarts, however the same message appears.
    When the PlayStation 3 is started up and you encounter the following message ‘The Hard disk’s database will be rebuilt’. When selecting ‘OK’ the system begins the operation and then fails (stopping the restoration of the HDD).
    There is an issue after the PlayStation 3 update process is started, or a rebuilding of the database occurs.
    Safe Mode procedure:
    1)    Ensure the PlayStation 3 is in standby mode (where the red light is apparent), and then turn the console off at the mains switch.
    2)    Turn the mains power on, then while in standby touch and hold the power button.
    3)    Keep your finger pressed on the power button (after 5 seconds you will hear a beep).
    4)    After 10 seconds of holding your finger on the power button, you will hear a second beep and the console will shut down (you can remove your finger).
    5)    Touch and hold the power button again.
    6)    Again hold your finger down on the button until you hear another beep after 5 seconds.
    7)    A number of seconds after this you will hear a double beep- you can remove your finger.
    8)    You will be prompted to plug your controller in and press the PS button on your controller. After doing so you will access the Safe Mode menu with a number of options.
    Safe Mode Option Screen:
    Restart System
    Selecting this option will start up the system normally- It will also allow you to exit the Safe Mode Menu.
    Restore Default Settings
    Selecting this option will restore Default settings on your console (when starting the unit you will be prompted to set time, time zone etc). This option will also delete your PlayStation Network account information from the system.
    Your User information will be deleted and restored- the indicator will be an asterix by your username e.g. *RabidWalker.
    When logging into your user you will encounter no issues with disc based games. However when attempting to play PSN downloaded games you may encounter the message:
    ‘To access the system, you must activate the system.
    Go to [PlayStation Network] > [Account Management] to activate this system. (80029514). ’
    Follow the instruction to activate your PlayStation 3 to play downloaded games (if the system is activated, deactivate and reactivate the system)
    Restore File System
    This option will begin a process to repair data on your Hard Disk Drive. Therefore it will check for any corrupted data and try and recover this. It the data cannot be recovered it may be erased to ensure that it does not interfere with the operation of the PlayStation 3.
    Rebuild Database
    If issues continue to persist and you select this option please note that data will be removed during this process.
    The following information will removed:
    -          Messages
    -          Playlists
    -          User changes to Information Screens
    -          User changes to Picture under Photos
    -          Video Thumbnails
    -          Video Playback History
    -          Video Resume Information
    This process may take same time to complete
    Restore PS3 System
    The option to restore PS3 system is the same as the ‘quick format’ option on the XMB menu. It will reformat the HDD, removing all data and restoring the Hard drive to its original state.
    System Update
    Selecting this option will install the PlayStation 3 Update but only if the update is on an external media storage device plugged into the console.
    This option can be used if any issues are encountered with the installation of the System software update.
    If you have any queries regarding this or any other issues please PM me or catch me on Twitter
    @RabidWalker
    Rabid
     

  • Mod function

    hi,
    i am trying to commit for every 1000 records.
    how to use mod function in following script?
    DECLARE
    v NUMBER;
    counter NUMBER;
    CURSOR r1 IS SELECT * FROM TAB1;
    BEGIN
    FOR c1 IN r1 LOOP
    v:=c1.ssn_id;
    counter := counter + 1;
    IF MOD(counter,1000 ) = 0 THEN
    dbms_output.put_line(v);
    commit;
    dbms_output.put_line(counter);
    counter := 0;
    END IF;
    END LOOP;
    END;
    could anyone help me for commiting every 1000th record.
    thanks in Advance.

    The only problem I see, is you did not initialize COUNTER.
    if you have counter := counter + 1; without initializing COUNTER, it is like adding NULL + 1 and this will always result in NULL
    declare
    cursor c1 is select ssn from TAB ;
    v_cnt number:=0;  -- NOTE YOU MUST INITIALIZE TO SOME NUMBER
    begin
      for c_rec in c1 loop
         v_cnt := v_cnt + 1;
         if mod(v_cnt,1000) = 0 then
            dbms_output.put_line('SSN: '||C_REC.SSN) ;
            dbms_output.put_line('v_cnt: '||v_cnt||' time to commit');
         end if;
      end loop;
    end;
    /

  • OWB10GR2 - Error when try to use 'MOD' function in an Expression

    Hi
    I'm trying to use the MOD function in an expression, e.g. mod(44,12), however, when I validate I get the error:-
    Line 2, Col 18:
    PLS-00201: identifier 'MOD' must be declared
    Line 0, Col 1:
    PL/SQL: Statement ignored
    Has anyone else come across this problem, and can anyone please suggest a solution?
    Thanks
    GB

    Not yet, thanks for the suggestion.
    If you use MOD in an expression or Constant, the expression does not validate but the mapping itself does validate, deploy and runs ok. So
    This issue has been reported as a bug therefore for the time being we can just ignore the expression validation message.

  • How to set mod function in TestStand

    I have trouble to use mod function in a TestStand seq under if condition. There is a syntax error of Unexpected token: MOD.
    I would like advice how to do this correctly. Thanks!
    Solved!
    Go to Solution.

    It should be 100 MOD 1000
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Any Mod function in JAVA?

    I did not find 'MOD' function in the Math class. Is there any 'MOD' function in Java?
    Thanks!

    What is your MOD function?
    Does the %-operator do what you need or do you want a strict mathematical modulus that returns only positive values?

  • Ultrabeat's pan mod function?

    Ultrabeat's pan mod function?
    Could someone please explain to me how Ultrabeat's pan mod function works?
    I know how to use automation in LPX's Tracks Area to automate panning but I'd like to avoid that on this occasion.
    I also tried using the LFO to modulate the panning but with limited success.
    And if anyone also knows if there's a good book specifically on Ultrabeat (pref published since the intro of LP9) that'd be awesome because most books don't go into the intricate parameters.

    duplicate post, see: http://forums.ni.com/ni/board/message?board.id=170&message.id=161086
    LabVIEW Champion . Do more with less code and in less time .

  • Using the MOD Function

    Can someone explain to me the syntax of the MOD function. In my Oracle9i book it states "The MOD function find the remainder of value1 divided by value2.
    In a simple sql statement I ran from my test db. For the life of me I cannot see where any division takes place.
    select employee_id, last_name, first_name, salary, mod(salary, 500)
    from employees;
    EMPLOYEE_ID LAST_NAME FIRST_NAME SALARY MOD(SALARY,500)
    100 King Steven 24000 0
    101 Kochhar Neena 17000 0
    102 De Haan Lex 17000 0
    103 Hunold Alexander 9000 0
    104 Ernst Bruce 6000 0
    105 Austin David 4800 300
    106 Pataballa Valli 4800 300
    107 Lorentz Diana 4200 200
    108 Greenberg Nancy 12000 0
    109 Faviet Daniel 9000 0
    110 Chen John 8200 200
    111 Sciarra Ismael 7700 200
    112 Urman Jose Manuel 7800 300
    113 Popp Luis 6900 400

    user12130369 wrote:
    In a simple sql statement I ran from my test db. For the life of me I cannot see where any division takes place.
    select employee_id, last_name, first_name, salary, mod(salary, 500)
    from employees;
    EMPLOYEE_ID     LAST_NAME    FIRST_NAME      SALARY     MOD(SALARY,500) 
    105                   Austin             David                 4800         300 
    113                   Popp             Luis                   6900         400
    For employee 105: 4800 / 500 = 9 remainder 300
    For employee 113: 6900 / 500 = 13 remainder 400
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Calculated member - Mode function

    Hello,
    I need some help. I am quite new to MDX; I've created a cube and the measure needs to behave same as the MODE function in Excel (the following
    link
    describes what the function does). Apparently the only way of achieving this is by MDX (calling the MODE function directly from Excel is not an option for me). Practically the member should return a single value, that represents the price that appears
    most times. There are 4 dimensions in my cube: dates, stores, products and client products. I need the following calculations:
    1. MODE(price) for specific Date, Product and Client Product. There will be multiple lines returned for this set, as there are multiple stores.
    2. MODE(price) for specific Store, Product and Client Product. There will be multiple lines returned for this set, as there are multiple dates.
    I found the below code online, that I've adapted to work against my cube, currently the query returns correct results for the first part, Mode(price) for multiple stores. I can change it to do the same for date. 
    What I need is to create 2 calculated measures using the last select and I am unsure how this can be achieved. Any help will be much appreciated or any other approach in achieving this.
    WITH 
    --Count how often each value appears
    MEMBER [Measures].[ValueCount] AS 
    SUM(  Union([Dim Stores].Store].CurrentMember.Level.Members,       {[Dim Stores].[Store].CurrentMember} AS CurrentStore),
    IIF( ([Dim Stores].[Store].CurrentMember, [Measures].[Price]) = 
    (CurrentStore.Item(0).Item(0), [Measures].[Price]) , 1, null))
    --Only get the items that appear the most
    SET [MaxModes] AS     
    ORDER(FILTER(NONEMPTY([Dim Stores].[Store].Members, {[Measures].[Price]}),    
    [Measures].[ValueCount] = MAX(NONEMPTY([Dim Stores].[Store].[Store].Members, [Measures].[Price]),    
    [Measures].[ValueCount])), [Measures].[Price], ASC)
    SELECT   {[Measures].[Price]} on 0,        
    [MaxModes]       
    --Filter out the duplicates        
    HAVING [MaxModes].CurrentOrdinal = 0 OR [Measures].[Price] <>             ([Measures].[Price], [MaxModes].Item([MaxModes].CurrentOrdinal - 2)) ON 1
    FROM [old_Prices_v2]
    WHERE {[Dim Date].[Date].&[2013-06-23T00:00:00]}*{[Dim Client Products].[Client Product].&[13]}*{[Dim Products].[Product].&[551]}

    I'm describing below what exactly is required:
    The cube has 4 dimensions (Date, Store, Product, Client Product) and one measure (Price). I need a measure to behave same as the MODE function in
    Excel (value that occurs most often). Practically the member should return a single value, that represents the price that appears most times. 
    While browsing the cube I need, for any combination of dimensions/hierarchies, to get the MODE of the price at its lowest grain (that is Date, Store,
    Product, Client Product). No need to aggregate the measure in any way. 
    For example if someone looks at a specific combination of Product & Client Product, the calculated measure would show the price that appears most
    times against that Product+Client Product, in any of the stores and in any of the dates.
    Example:
    Date
    Store Product
    Client Product
    Price
    05-Feb-2013
    Store1 Prod1
    ClProd1 50
    05-Feb-2013
    Store1 Prod1
    ClProd1 60
    06-Feb-2013
    Store2 Prod1
    ClProd1 60
    06-Feb-2013
    Store2 Prod1
    ClProd1 70
    05-Feb-2013
    Store1 Prod1
    ClProd2 80
    05-Feb-2013
    Store1 Prod1
    ClProd2 50
    06-Feb-2013
    Store2 Prod1
    ClProd2 50
    06-Feb-2013
    Store2 Prod1
    ClProd2 70
    Case1: If one looks at Prod1 & ClProd1 then the MODE(Price) is 60 as there are 4 rows to be aggregated and the value that repeats most is 60
    Case2: If one looks at Prod1 & ClProd1 & Store1 then the MODE(Price) is either 50 or 60 as there are 2 rows to be aggregated and both 50 and
    60 repeat 1 time. I this case any of them can be returned (act like TOP 1 in TSQL)
    Case3: If one looks at Prod1 & Store1 then the MODE(Price) is 50 as there are 4 rows to be aggregated and the value that repeats most is 50
    Case3: If one looks at Prod1 & 06-Feb-2013 then the MODE(Price) is 70 as there are 4 rows to be aggregated and the value that repeats most is 70.
    Any guidance will be much appreciated!
    Thank you in advance.
    Mihai

  • Using TabbedTextOut function to output text, the text will be truncated

    In standard C++, I am using 'TabbedTextOut()' function to output text.
    My application calls the function more than once with the parameter 'nTabOrigin' set to the same value each time. So that
    I call 'TabbedTextOut' function several times for a single line.
    Such as I output text 'jumpto A', firstly I output 'jumpto' by using ''TabbedTextOut(...)', then I output ' A' by using 'TabbedTextOut(...)'.
    But I found that the character 'o' had been truncated. When the font was set 10, the phenomenon was obvious. Is it a bug of this API? 

    It's OK for me, could you share your code snippets?
    Best Regards,
    Please remember to mark the replies as answers if they help

Maybe you are looking for

  • Exporting reports form SAP to MS Excel file

    Dear All Our material number logic is like that having 18 digits "801062004767100001". 1. When we are exporting any std report or zreports  to excel through Export to excel all the numbers are converting in to text and saving in excel file as it is d

  • MRP Behaviour

    Hi, PP experts The scenario is relates to MRP, actually in my company all the materials are set as moving average with price indicator "V" in material master and based on the materials when we run the MRP the system generate the requirement for procu

  • Watching iTunes movie on iPhone.

    I have several movies (mp4) in my iTunes library on my iMac.  Can I select and watch them on my iPhone5 over my home network?

  • Video to USB transfer, not all clips veiwable on pc

    So I like making vids on my downtime and would use sharefactory to make videos. Although Sharefactory doesn't give the justice with very little editing options. I decided to start transferring my videos to pc where i have adobe premiere pro to edit.

  • Warning message in logs..

    Hi All, How do i remove this warning from my server log???? why does this occur??? 15:28:22,687 WARN [loggerI18N] [com.arjuna.ats.internal.jta.recovery.xarecovery1] Local XARecoveryModule.xaRecovery got XA exception javax.transaction.xa.XAExcepti on,