EzDev.org

roundup

eliminate bugs and weeds from shell scripts roundup


How can I round up values in PHP [duplicate]

This question already has an answer here:

I want to round up the values in PHP. please suggest me any function how to implement the values in round.

example how to convert it round as below:

803   --> 800 

791.5 --> 790

811   --> 810

845.7 --> 850

850.6 --> 860

900.5 --> 900

1016.9 --> 1020

Source: (StackOverflow)

Round up values of text box in C# [on hold]

I want to Roun d Up Values Like This...

0.1 will be 0

0.3 will be 0

0.5 will be 1

0.9 will be 1

Is there any way to solve it in c#?

Thanks in Advance...


Source: (StackOverflow)

Roundup function javascript [closed]

In excel, we have a function: ROUNDUP(number,num_digits)

Is there same function in javascript?

Please help me.


Source: (StackOverflow)

How to perform Excel ROUNDUP function in SQL Server 2005

Hi how can we do Excel ROUNDUP function in SQL Server 2005 ?

Below is my test case:

In Excel:

=ROUNDUP(1/100,0)*0.25 = 1

=ROUNDUP(10/100,0)*0.25 = 1

In SQL Server 2005:

SELECT (ROUND(CAST(1 AS decimal(18,4))/100,0)) = 0.0000

which is really diffirent.

Thanks and Regards


Source: (StackOverflow)

roundup apache on windows configuration

I have installed round up issue tracker on windows 7 along with python 2.7.9. I am able to run the round up server separately but have not been able to run the server with apache (I have xampp 1.7.4 installed).

httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<IfModule mod_proxy.c>
ProxyPass /demo/ http://localhost:8080/testing/
<IfModule mod_proxy_ajp.c>
Include "conf/extra/httpd-ajp.conf"
</IfModule>
</IfModule>

(roundup) config.ini

[tracker]

name = Roundup issue tracker

web = http://localhost/ 

when i start the round up server I get the message "Roundup server started at localhost:8080" but it doesn't run on the browser. How do I get it to work with apache?


Source: (StackOverflow)

How to round a number up and add numeric punctuation

I've got the following pen: http://codepen.io/anon/pen/LVLzvR

I cant quite figure out how to round the number up so you don't break the punctuation. I need to round the number up as I don't want to see a value like 33,333.,333

 //ADDS PUNCTUATION EVERY THREE CHARACTERS
  $('input.numericpunctuation').keyup(function(event){

      var oNum= $(this).val(); // USE THIS NUMBER FOR CALCULATION

      var num = oNum.replace(/,/gi, "").split("").reverse().join("");

      var num2 = RemoveRougeChar(num.replace(/(.{3})/g,"$1,").split("").reverse().join(""));

      console.log(num2);
      console.log(oNum);

      // the following line has been simplified. Revision history contains original.
      $(this).val(num2);
  });

function RemoveRougeChar(convertString){


    if(convertString.substring(0,1) == ","){

        return convertString.substring(1, convertString.length)            

    }
    return convertString;

}

Example input event: If I input 5555, is expect to see (and do see) 5,555. However if I add 5555.55 I get 5,555,.55. Ideally id like to round the number up removing the decimal.


Source: (StackOverflow)

F# round up to a specific number of decimal places

for example I can use System.Math.Round((float),2)to round my float to the nearest 2 decimal places, but is there anyway in F# that i can round up my float to 2 decimal places? Thanks


Source: (StackOverflow)

Java - unexpected result when rounding a double/float to 2 decimals

I encounter a problem when round a double to 2 decimals. I know this questions have been asked in many places. But my question is slightly different and I cannot find it in other places.

So far as I know, there are 2 ways to do this.

  1. Math.round(double*100.0)/100.0
  2. DecimalFormat(“###.##”)

I am trying to use the first way: a custom way to round double. When the second decimal is 0, the result will only print the first decimal and ignore the second one.

For example,

  1. Math.round(1.23333*100.0)/100.0 The result is 1.23. This works good.
  2. Math.round(3.90*100.0)/100.0. The result is 3.9. Problem occurs. I want to show 3.90 instead of 3.9
  3. Math.round(3*100.0)/100.0. The result is 4.0. I want 4.00 instead of 4.0

So, my question is that how I can have a double value with 2 decimals no matter if the last decimal is 0 or not. I know I can use the second way- DecimalFormat(“###.##”) to achieve what I want! But is it possible to do it by using the first way?

Edit: Thanks for the answers. It looks like it is NOT possible to use the round() method to achieve it. However, some people suggest to use the combination of 2 ways to achieve it. But I think using only DecimalFormat(“###.##”) can get what I want. Can anyone confirm it?


Source: (StackOverflow)

Round up decimals to 3 numbers after

I have got this script which multiplies value inputted into input field by dropdown's value assigned through span data-val.

How can I make the script show result rounded up to 3 decimals?

$(document).ready(function () {
    function showTab(name) {
        $('div.fruit').hide();
        var $div = $('#' + name).show();
        var number = parseInt($('.number').val(), 0);
        $('span', $div).each(function () {
            $(this).text($(this).data('val') * number);
        });
    }

    $('#update').click(function() { 
        showTab($('#dropdown').val());
    });

    showTab($('#dropdown').val());
});

Source: (StackOverflow)

Modifying SQL to use a different table in a select statement

I'm trying to change the date search behavior in my roundup install, but SQL is not my strong suit. Here is the existing query:

select _issue.id,_issue._activity,(_issue._activity is not NULL),
    _priority3._order,(_priority3._order is not NULL) from _issue
LEFT OUTER JOIN _priority as _priority3
    on _issue._priority=_priority3.id
where _issue._activity >= '2015-01-16 08:00:00.000' and
    _issue._activity <= '2015-01-17 07:59:59.000' and
    _issue.__retired__=0
order by (_priority3._order is not NULL),_priority3._order,
    (_issue._activity is not NULL),_issue._activity,_issue.id

Here are the tables with the interesting fields:

table:  _issue
fields: id         (integer)
        _activity  (timestamp)
        _priority  (integer)

table:  _priority  (alias priority3)
fields: id         (integer)
        order      (real)

The tables I need to use:

table:  issue_messages
fields: linkid     (integer, id of message)
        nodeid     (integer, id of issue)

table:  _msg
fields: id         (integer)
        _activity  (timestamp)

What I want is a list of issues that had any activity, which means checking the message activity date, not the issue activity date (which only reflects the last activity).


Source: (StackOverflow)

Swift Round up / Max the NSDecimalNumber

Let's say we have an NSDecimal constant called total and it contains the value of 3.33333333 divided by 10/3. 10 and 3 are both NSDecimalNumber. We want the total to be 4 as an NSDecimalNumber in Swift.

let total = ten/three

// the ideal total would be rounded up whenever there is a floating 

in the doc. we have

func NSDecimalRound(_ result: UnsafeMutablePointer<NSDecimal>,
                  _ number: UnsafePointer<NSDecimal>,
                  _ scale: Int,
                  _ roundingMode: NSRoundingMode)


maximumDecimalNumber()

Which one is the best fit for calculator with currency style? Please include an example each how to use them if you know so. Thank you .


Source: (StackOverflow)

Always Round UP a value in C#

I want to roundup value according to the 3rd decimal point. It should always take the UP value and round. I used Math.Round, but it is not producing a result as i expected.

Scenario 1

var value1 = 2.526;
var result1 = Math.Round(value1, 2); //Expected: 2.53 //Actual: 2.53

Scenario 2

var value2 = 2.524;
var result2 = Math.Round(value2, 2); //Expected: 2.53 //Actual: 2.52

Scenario 1 is ok. It is producing the result as i expected. In the 2nd scenario I have amount as 2.522. I want to consider 3rd decimal point (which is '4' in that case) and it should round UP. Expected result is 2.53

No matter what the 3rd decimal point is (whether it is less than 5 or greater than 5), it should always round UP.

Can anyone provide me a solution? I don't think Math.Round is helping me here.


Source: (StackOverflow)

How can I use Math Ceiling RoundUp How to determine even odd number

I need to print data from a DataGridView on both sides of a preprinted form but:

  1. Each side has different arrangement for that info.
  2. Each side can only hold info from tree rows, so:
  3. 1st, 2nd and 3rd row go on side 1;
  4. 4th, 5th and 6th row go on side 2;
  5. 7th, 8th and 9th row go on side 1;
  6. 10th, 11th and 12th go on side 2; and so on.

I will select which group to print.

I’m planning to do it this way: enter image description here

  1. ((row.Index) +1) / 3,
  2. round it up, with no decimals, to get an integer, (like in the above excel image),
  3. MOD that integer by 2, (like in the above excel image).

If the result of that MOD by 2 is 1, then it will print Side 1 arrangement, if the result of that MOD by 2 is 0, then it will print Side 2 arrangement.

  • How do I do it in C#? I'm using VS2010 Express Edition. Also, I wanted to use System.Math.Ceiling but I get a Namespace, decimal, double-precision and floating-point number warnings or errors.

Source: (StackOverflow)

Roundup total and multiply again jquery calculator

I have a few modifications I need for my cost calculator:

  1. Is there a way to add a Math.celi to the no of cans so it rounds up to the nearest whole number, providing the minimum cans needed?

  2. What ever the minimum required cans are, can the cost reflect that by multiplying by 18.23 and giving the real amount?

    $('input').keyup(function () { // run anytime the value changes
    
    
     var firstValue = parseFloat($('#width').val()); // get value of field
     var secondValue = parseFloat($('#height').val());
     var thirdValue = parseFloat($('#per-can').val()); // convert it to a float
     var forthValue = parseFloat($('#cost').val());
     var fithValue = parseFloat($('#size').val());
    
     var canCount = firstValue * secondValue / thirdValue;
    
     $('#added').html((canCount * forthValue).toFixed(2));
     $('#cans').html(canCount.toFixed(2));
    
     if (Math.ceil(canCount) < 2) {
     $('#error').html("Need at least 1!");
     } else {
     $('#error').empty();   
     }
    
     });
    

http://jsfiddle.net/5xzSy/504/ thanks


Source: (StackOverflow)

malloc. How works the algorithm for round up [duplicate]

This question already has an answer here:

Looking the code of the malloc we can see that it performs round up like this:

nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1;

I understand why we perform

(nbytes + sizeof(Header)) / sizeof(Header)

But the other hand I don't understand why we need to subtract -1 in numerator and +1 in denominator ?


Source: (StackOverflow)