Show decimal if needed In odoo pos ticker - odoo-12

How can I remove trailing zeroes from a floating point number? Ex: If my number is 1.000, it should display 1 and if the quantity is 1.250, it should show only 1.25.
I tried to change it from Settings -> Database Structure -> Decimal Accuracy with Digits after comma=0, but I won't be able to sell a product with a quantity of 0.5.

Related

Create text string based upon money value Flutter

Can any one Provide me the information on how to create a text String based upon money value.
example:
Negative value: -237.16
Expected output: minus two hundred and thirty seven pounds and sixteen pence
Zero value: 0.00
Expected output: zero pounds and zero pence
Positive value: 237.16
Expected output: two hundred and thirty seven pounds and sixteen pence.
(1) Create your database (it can be a List and/or Map), like this:
(2) Parse your number: it is negative or positive, it is integer or decimal
(3) According to length of whole part and decimal part, combine number words from your database and get your string wished.
There is this package numbers_to_words

gtsummary decimals mean and SD - changing defaults

I would like to obtain 3 decimals for continuous variables outputs in gtsummary for both mean and SD. In the default setting it exports 2 decimals; in a prior post there is a way to change the percentage in categorical variables to 1 decimal
# set theme where percentages are rounded to 1 decimal place
set_gtsummary_theme(list(
"tbl_summary-fn:percent_fun" = function(x) sprintf(x * 100, fmt='%#.1f')
))
Is there a way to change it for Mean and SD for continuous variables?
Thanks!
#gtsummary
The default number of decimal places for continuous variables to be rounded isn't 2 decimal places. The number of decimal places is determined by the spread of the data, e.g. variables with large spread may be rounded to the nearest integer, and variables with a small spread may be rounded to 2 or 3 decimal places. Unfortunately, there is no way to change the default globally. You'll need to use the tbl_summary(digits=) argument to change number of decimal places a variable's summary statistics are rounded to.

How To Only Show Certain Number of numbers after decimal point Double Swift

I am using doubles to log hours for my app. My problem is I only want to record the number and the first number after the decimal place otherwise sometimes the number becomes like this (x.9000000000001) and I only need the x.9.
I have tried rounding the double value but it still has this weird extra amount of zeros.
Any way to only get the double to show the first number after decimal place.
Thanks
The easiest way to achieve rounding to the first decimal place is to simply do the following:
let x = 4.9000000001
let roundedX = Double(round(x * 10) / 10) // roundedX = 4.9
roundedX will be a Double representing x rounded to the first decimal. To get 2 decimal places, just multiply and divide by 100 instead of 10.

printf number format for constant width lat/long in exiftool

Apparently I am misunderstanding the printf man page. (Or else it's a bug in exiftool 10.55 and 10.77)
I am trying to get GPS coordinates from image files with exiftool. I would like to make them the same width and without unnecessary spaces.
The format string I tried, and one of the results:
-coordFormat "%03d°%02d′%0d%02.5f″"
042°37′280.00000″ N, 002°05′510.00000″ W
(I don't need five decimal places—I just put that in temporarily to see whether any of the cameras wer being dishonest about the precision.) The three unnecessary spaces can't be helped; they are outside the format string’s control, but I did get rid of others that were in the default.  The leading zero for latitude isn't needed, but it is there because longitude uses the same format string.  One problem is the bogus zero inserted between floor(seconds) and its decimal point. The other problem is the false fractional part.  The default format for that file is 42 deg 37' 28.39" N, 2 deg 5' 51.96" W
Someone's "cheat sheet" said that my second digit should be the total width, including the decimal point, so I changed the seconds to "%08.5f" but all that did was add another bogus zero in front of the decimal point, e.g., 510.00000→5100.00000 (width of ten, not eight!).
A few years ago, I did something similar, and got the correct results.  But I didn't bother to save the script "for future reference."
(Several other SO answers agree with that "cheat sheet.")
It looks like the issue is with the seconds field, for which you have the format specifier %0d%02.5f. I'm not sure what you intended, but there can be only one % for each value to be rendered
If you're formatting longitude then you are dealing with values between -180 and 180. If you want five decimal points then the total width will be
One character for the sign + or -
Three characters for the integer part
One character for the decimal point .
Five fractional digits
giving a total field width of ten. Your full specifier will be %0+10.5f, giving output between «-180.00000» and «+180.00000»
You may use a space flag instead of the +, as in %0 10.5f, which will use a space instead of a + to indicate a positive number, rendering 180 as « 180.00000». The leading zero is there so that zeroes are use to fill the full ten character field with
When dealing with latitude, you will need a total width one character smaller. %0+9.5f will result in a range of «-90.00000» to «+90.00000». Of course you may use the same format specifier as for longitude, which will produce «-090.00000» to «+090.00000». This way the latitude and longitude seconds will have the same number of characters
The %0d is throwing you off. That part of the template is consuming the "51.0" seconds component of the coordinate, leaving nothing for the %02.5d part of the template.
printf "%0d", 51 ===> "51"
printf "%02.5f"; ===> "0.00000"
printf "%0d%02.5f", 51 ===> "510.00000"
So lose the %0d.
The 2 in %02.5f also doesn't do you any good. The number before the decimal place is the minimum length of the field, and the number after the decimal place is the number of decimal places to use. Since 5 decimal places will be printed, the output will be at least 7 characters, and the 2 value will be ignored.
First number is the width, second number is the number of decimal points so what you have currently (%2.5f) appears to be backwards. %5.2f would give you a number that occupies 5 characters and has 2 decimal places. For a number as big as 510, you probably want to make it %6.2f

"Round" 2530.30 to 2599 in Postgres

I need to replace numbers like 2530.30 with 2599 in PostgreSQL.
I tried using ROUND(2530.30)+0.99 but it only changes the numbers after the decimal point to 99. So it results in 2530.99, which I don't want.
I want to remove fractional digits and replace the last two decimal digits with 99. I know I can just use an integer, but my assignment at school says I need to do this.
There should no be negative numbers, the assignment says that I should have a product that is sold for, let's say, 3500.50 dollars, I then need to make this number go from 3500.50 to 3599. Not 3500.99.
Divide by 100, truncate, multiply by 100 again:
SELECT trunc(2530.30 / 100) * 100 + 99;
This replaces all numbers in the range [2500, 2600) with 2599.
Or, in more general terms, it replaces the last two decimal digits with 99 and discards fractional digits (which also transforms 0 or 12.50 to 99).
Negative numbers cannot occur, as you say, so ignored.