Skip to main content
Participating Frequently
Feb 13, 2023 6:54 AM UTC
Question

Roundup

Hi All,

We are using Universe 11.3 on Windows.

I needed to round a 5DP number up to the Next Whole number, so the result would be ;



I could not find a suitable command equivalent to Excel  ROUNDUP, as shown above, so I've manually programmed the required calcs.

There does not seem to a be suitable Flag for ICONV / OCONV and INT only grabs the whole number

Is anyone aware of a Function that does what I needed ??

Just in case I've missed a  Function, i went through the  UV Basic Command 11,34 pdf guide and could not find anything.

However, i spotted in UV Basic Command 12.11 there are 2 x new commands ROUND and also TRUNC

Whilst these syntactically don't do what it need, it may help others looking for similar functionality.

so as I'd found these new Functions available in V12, it got me thinking, can these new commands be retro applied to earlier versions of UV, obviously I can't just upgrade Universe to access these commands.

Secondly as the new to me ROUND function still does not do the same as EXCEL ROUNDUP, is there process to request our ROCKETEER colleagues to investigate and include an equivalent ROUNDUP function ?

and finally is there a simple guide to explain the new functions and features that have been added to newer versions of Universe ??

Many Thanks

Andy


    4 replies

    Gregor Scott
    Participating Frequently
    Feb 13, 2023 6:52 PM UTC

    Hi All,

    We are using Universe 11.3 on Windows.

    I needed to round a 5DP number up to the Next Whole number, so the result would be ;



    I could not find a suitable command equivalent to Excel  ROUNDUP, as shown above, so I've manually programmed the required calcs.

    There does not seem to a be suitable Flag for ICONV / OCONV and INT only grabs the whole number

    Is anyone aware of a Function that does what I needed ??

    Just in case I've missed a  Function, i went through the  UV Basic Command 11,34 pdf guide and could not find anything.

    However, i spotted in UV Basic Command 12.11 there are 2 x new commands ROUND and also TRUNC

    Whilst these syntactically don't do what it need, it may help others looking for similar functionality.

    so as I'd found these new Functions available in V12, it got me thinking, can these new commands be retro applied to earlier versions of UV, obviously I can't just upgrade Universe to access these commands.

    Secondly as the new to me ROUND function still does not do the same as EXCEL ROUNDUP, is there process to request our ROCKETEER colleagues to investigate and include an equivalent ROUNDUP function ?

    and finally is there a simple guide to explain the new functions and features that have been added to newer versions of Universe ??

    Many Thanks

    Andy


    The current conversion codes do not play well with real numbers, and there is no simple conversion code that will round any decimal number UP to the next integer (I'm no conversion code expert, so it might be possible with a more complex "A" or "F" conversion).

    The quickest path to achieving what you need at the moment is to simply add 0.5 to the real number and pass it though the OCONV using "MR00".
    The "MR00" rounds to the nearest whole number, so by always adding 0.5 to the value you ensure you round up to the desired target whole value.

    >OCONV 175.42175 MR00
    OCONV('175.42175','MR00') = '175'

    >OCONV 175.92175 MR00
    OCONV('175.92175','MR00') = '176'

    >OCONV 175.62175 MR00
    OCONV('175.62175','MR00') = '176'

    >OCONV 176.12175 MR00
    OCONV('176.12175','MR00') = '176'

    Manu Fernandes
    Inspiring
    Feb 14, 2023 9:20 AM UTC

    Hi All,

    We are using Universe 11.3 on Windows.

    I needed to round a 5DP number up to the Next Whole number, so the result would be ;



    I could not find a suitable command equivalent to Excel  ROUNDUP, as shown above, so I've manually programmed the required calcs.

    There does not seem to a be suitable Flag for ICONV / OCONV and INT only grabs the whole number

    Is anyone aware of a Function that does what I needed ??

    Just in case I've missed a  Function, i went through the  UV Basic Command 11,34 pdf guide and could not find anything.

    However, i spotted in UV Basic Command 12.11 there are 2 x new commands ROUND and also TRUNC

    Whilst these syntactically don't do what it need, it may help others looking for similar functionality.

    so as I'd found these new Functions available in V12, it got me thinking, can these new commands be retro applied to earlier versions of UV, obviously I can't just upgrade Universe to access these commands.

    Secondly as the new to me ROUND function still does not do the same as EXCEL ROUNDUP, is there process to request our ROCKETEER colleagues to investigate and include an equivalent ROUNDUP function ?

    and finally is there a simple guide to explain the new functions and features that have been added to newer versions of Universe ??

    Many Thanks

    Andy


    hi,

    do it with basic 

    INPUT A 
    PRINT (INT(ABS(A)) + (MOD(ABS(A),1)>0 )) * (IF A < 0 THEN -1 ELSE 1 )
    

    use it in a user_exit 

    * use it as usr exit format 
    SUBROUTINE OCONV_ROUNDUP(ANS,STATUS,DATA,TYPE)
    IF NUM(DATA) THEN 
         ANS = (INT(ABS(DATA)) + (MOD(ABS(DATA),1)>0 )) * (IF DATA < 0 THEN -1 ELSE 1 )
    END ELSE 
         ANS = DATA  
    END 
    RETURN 
    
    CATALOG prog OCONV_ROUNDUP $OCONV_ROUNDUP 
    * in basic 
    PRINT OCONV(A,'UOCONV_ROUNDUP') 
    * in field dict 
    conv = 'UOCONV_ROUNDUP' like MCU ... 
    

    build a function 

    * use it as a function 
    FUNCTION ROUNDUP(DATA)
    IF NUM(DATA) THEN 
         ANS = (INT(ABS(DATA)) + (MOD(ABS(DATA),1)>0 )) * (IF DATA < 0 THEN -1 ELSE 1 )
    END ELSE 
         ANS = DATA  
    END 
    RETURN ANS 
     
    CATALOG prog ROUNDUP 
    * inbasic 
    DEFFUN ROUNDUP( DATA) CALLING "ROUNDUP"
    PRINT ROUNDUP(A)
    

    manu

    Participating Frequently
    Feb 14, 2023 10:01 AM UTC

    Hi All,

    We are using Universe 11.3 on Windows.

    I needed to round a 5DP number up to the Next Whole number, so the result would be ;



    I could not find a suitable command equivalent to Excel  ROUNDUP, as shown above, so I've manually programmed the required calcs.

    There does not seem to a be suitable Flag for ICONV / OCONV and INT only grabs the whole number

    Is anyone aware of a Function that does what I needed ??

    Just in case I've missed a  Function, i went through the  UV Basic Command 11,34 pdf guide and could not find anything.

    However, i spotted in UV Basic Command 12.11 there are 2 x new commands ROUND and also TRUNC

    Whilst these syntactically don't do what it need, it may help others looking for similar functionality.

    so as I'd found these new Functions available in V12, it got me thinking, can these new commands be retro applied to earlier versions of UV, obviously I can't just upgrade Universe to access these commands.

    Secondly as the new to me ROUND function still does not do the same as EXCEL ROUNDUP, is there process to request our ROCKETEER colleagues to investigate and include an equivalent ROUNDUP function ?

    and finally is there a simple guide to explain the new functions and features that have been added to newer versions of Universe ??

    Many Thanks

    Andy


    Thanks Manu,

    your solution was simpler and more elegant than mine.

    Be good if Rocket could just provide a new ROUNDUP Function like they have done in V12 and newer, with the ROUND function, as the ROUND function still does not deliver what i needed

    Thanks again

    Andy 

    Will Johnson
    Participating Frequently
    Feb 15, 2023 11:53 AM UTC

    Hi All,

    We are using Universe 11.3 on Windows.

    I needed to round a 5DP number up to the Next Whole number, so the result would be ;



    I could not find a suitable command equivalent to Excel  ROUNDUP, as shown above, so I've manually programmed the required calcs.

    There does not seem to a be suitable Flag for ICONV / OCONV and INT only grabs the whole number

    Is anyone aware of a Function that does what I needed ??

    Just in case I've missed a  Function, i went through the  UV Basic Command 11,34 pdf guide and could not find anything.

    However, i spotted in UV Basic Command 12.11 there are 2 x new commands ROUND and also TRUNC

    Whilst these syntactically don't do what it need, it may help others looking for similar functionality.

    so as I'd found these new Functions available in V12, it got me thinking, can these new commands be retro applied to earlier versions of UV, obviously I can't just upgrade Universe to access these commands.

    Secondly as the new to me ROUND function still does not do the same as EXCEL ROUNDUP, is there process to request our ROCKETEER colleagues to investigate and include an equivalent ROUNDUP function ?

    and finally is there a simple guide to explain the new functions and features that have been added to newer versions of Universe ??

    Many Thanks

    Andy


    Weird they call it "Round UP" when your negative number example is actually rounding down

    Begin case

    case a < 0; a = int(a-0.99999)

    case a >= 0; a = int(a+0.99999)

    end case