rounding

Calculate round retail prices for opencart

Deadly 提交于 2019-12-13 05:58:08
问题 Maybe someone has a clue. I want to round the retail prices to nice numbers in opencart. Base calculation is: (wich should produce € 1,50 - €2,00 - € 2,50 etc) $price = sprintf("%.2f", round($pice * 2) / 2); I thought i'dd do it like this in controler/product/product.php but that ain't working. I don't want to edit all theme .tpl so it has to be done in the opencart code. Now i have this but I get values of €0.49 or €0.99 $price_new = $this->tax->calculate($result['price'], $result['tax_class

How can I round an integer to the nearest 1000 in Pascal?

牧云@^-^@ 提交于 2019-12-13 05:43:52
问题 I've got a Integer variable in Pascal. Is there any possible function I can use that can round that value to the nearest 1000, for example: RoundTo(variable, 1000); Does anything of the sort exist? Or is there another method I should try using? Thanks! 回答1: The general solution for this kind of problem is to scale before and after rounding, e.g. y = 1000 * ROUND(x / 1000); 回答2: Use RoundTo(variable, 3) . The second parameter specifies the digits you want to round to. Since you want to round

Double to int rounding normal way from .5 [duplicate]

故事扮演 提交于 2019-12-13 04:35:59
问题 This question already has answers here : Division of integers in Java [duplicate] (7 answers) Closed 5 years ago . I'm making calculation and for that I'm using the following expression: Player.targetx = (int) (((e.getX() - Frame.x)/(Screen.myWidth/World.worldWidth))-8); For example: if the values are (((103 - 40)/(1184/15))-8) the double answer is around -7.20186 . Player.targetx still gets value of -8 . Why's that? I would like to make it so that -7.5 gives me answer of -8 and anything like

Magento paypal rounding issue with Discount

懵懂的女人 提交于 2019-12-13 02:55:43
问题 I'm using magento 1.9.1.0, and HUF curency that has no cents. If i don't use discount there is no rounding error, but if i do use inside magento it calculates well: But as soon as I try to use paypal to pay it i get the following error: and I check the paypal button code i get this: <img src="https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image&buttontype=ecshortcut&locale=en_US&ordertotal=5326.80&pal=XXXXX" alt="Checkout with PayPal" title="Checkout with PayPal"> and the ordertotal is

Is NSDecimalNumber really necessary to do some quite simple tasks?

你。 提交于 2019-12-13 02:01:52
问题 It started quite normally. I'm writing complex calculation application for iPhone. I decided to use float primitive for representing numbers. So, time came to start rounding and formatting output, but first of all rounding. I want to round numbers to different number of decimal places. FOund out there is no useful C function. OK, so I can write my own. But then I have numbers from application settings to persist. I found out only objects can be persisted. So I started to dig in NSNumber and

Does terraform support math rounding?

China☆狼群 提交于 2019-12-13 00:42:04
问题 Is it possible to round an integer value in terraform string interpolations? 回答1: It's a bit of a hack and doesn't use terraform string interpolations but.. You can do this with the external data source (https://www.terraform.io/docs/providers/external/data_source.html) by delegating it to another program. The example I've included uses bash and jq. However you could probably achieve this without jq. Terraform: data external "rounder" { program = ["bash", "${path.module}/round.sh"] query {

OpenCv round after division

喜夏-厌秋 提交于 2019-12-13 00:34:23
问题 Looking at the following code Blue = channel[0]; Green = channel[1]; Red = channel[2]; Mat G = (Green + Blue) / 2; where Red Green and Blue are the channels of an image. Where the sum of Green and Blue is odd, sometimes it make a round and sometimes a "fix". For example for a Green pixel with value 120 and Blue 45, the G value is 82 (so that it takes just the integer part of 82,5). While in another case where the Green is 106 and the Blue is 33 i get the value 70 for that element of G (so

Formatting tooltip value with StandardXYToolTipGenerator

烂漫一生 提交于 2019-12-12 19:29:12
问题 In desktop Java project I used StandardXYToolTipGenerator for generating tooltips on chart. Renderer was configured as below: renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} - {2} ({1})",new SimpleDateFormat("HH:mm:ss"), NumberFormat.getNumberInstance())); Where {2} is value (example 1.149431) but when I am using NumberFormat it format itself and return value 1.149, I want get precisely rounding. How to get it? Any idea? I tried extend NumberFormat class, but method

How to round numeric output from yaml.dump, in Python?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 19:19:47
问题 Is there a clean way to control number rounding output of yaml.dump ? For example, I have a class with different complexity variables, some of which are double precision numbers I want to be round to say 4th digit. This yaml output is for display only; it will not be loaded (i.e. yaml.load will not be used). As a naive example, consider class A below: import yaml class A: def __init__(self): self.a = 1/7 self.b = 'some text' self.c = [1/11, 1/13, 1/17, 'some more text'] def __repr__(self):

Using round function in R on very small values returns zero

偶尔善良 提交于 2019-12-12 18:22:21
问题 I sometimes have to deal with very low p values and present them in a tabular format. The values returned by R can have long significance digits (i.e. digits after the decimal point). Now since the p value is anyways so low , I tend to shorten them before writing them into a .xls or .tsv files.(Just to make the tables look pretty !!) I am using R version 3.0.0 (2013-04-03) Some background and examples : 9.881313e-208 in R will be 9.88e-208 in my table I can use the round function in R to do