Qdoublespinbox does not allow values less than 1 - c++

Qdoublespinbox does not allow values less than 1, decimal values with precision grater than 1, values in positive range 0.00 - 0.99 (for example). There is no problem with setting it´s value to 1.1, 1.11, 1,04, but not 0.5 .... it is rounding up anyway to 1.
I have tried setting range to negative values with precision, setting explicitly the numbers of decimals and the minimum value of the widget, but all for nothing.

You can have a look at the Spin Boxes Example (accessible through QtCreator/Welcome/Examples or https://doc.qt.io/qt-5/qtwidgets-widgets-spinboxes-example.html).
You can have float or double precision rounding issues if you get your values from a calculation with not enough precision in memory.
You can also force the local to accept dot as decimal separator as you seem to mix comma and dot: add QLocale::setDefault(QLocale::C); at the beginning of your program. You can also create a custom double validator to accept both dot and comma by inheriting QDoubleValidator.

Related

Identify the value with highest number of decimal values

I have a range of values and I want to count the decimal points of all values in the range and display the max count. the formula should exclude the zeroes at the end(not count ending zeroes in the decimal points).
for example, in the above sample, in the whole range the max of count of decimal places is 4 excluding the ending zeroes. so the answer is 4 to be displayed in cell D2
I tried doing regex, but do not know how do I do it for a whole range of values.
Please help!
try:
=INDEX(MAX(LEN(IFERROR(REGEXEXTRACT(TO_TEXT(A2:C4), "(\..+)")*1))-2))
Player0's solution is a good start, but uses TO_TEXT which seems to rely on the formatting of your cells.
If you want to safely compute the number of decimal places, use the TEXT function instead.
TEXT(number, format) requires a format whose max. number of decimal places has to be specified. There is no way around this, because formulas like =1/3 can have infinitely many decimal places.
Therefore, first decide on the max, precision for your use-case (here we use 8). Then use below function which works independently from your document's formatting and language:
=INDEX(MAX(
LEN(REGEXEXTRACT(
TEXT(ABS(A2:C4); "."&REPT("#";8));
"[,.].*$"
))-1
))
We subtract -1 since LEN(REGEXEXTRACT()) also counts the decimal separator (. for english, , for many others) .
Everything after the 8th decimal place is ignored. If all your numbers are something like 123.00000000987 the computed max. is 0. If you prefer it to be 8 instead, then add ROUNDUP( ; 8):
=INDEX(MAX(
LEN(REGEXEXTRACT(
TEXT(ROUNDUP(ABS(A2:C4);8); "."&REPT("#";8));
"[,.].*$"
))-1
))

Strange number formating in ssas tabular?

I have a ssas tabular cube. I have a question regarding formatting here:
I have number 1,000,000,000.5
By using format: #,##0,.0
it gets displayed as: 1,000,000.5
I have 2 questions:
What's the logic? how is #,##0,.0 instructing to remove 000?
Also, i would like to get rid of the decimal, and show it like 1,000,000 How can I do it?
Commas before the decimal point that are not followed by # or 0 divide the result by 1000.
Whatever digits it shows will be rounded to that precision. If you want to drop the decimal rather than rounding, you can use TRUNC or INT in the measure definition.
If you use the following format #,### will give you the following.

XSLT - Round up to two decimal places

There is a requirement to round the value up(always) to two decimal places. meaning, the number 8.3333333 should become 8.34. Round and format-number functions do not seem to achieve this. Does anyone have an idea on how to get the desired output using xslt transformation please?
To round up a number with precision of two decimal places:
ceiling(100*$value) div 100
If you need trailing zeros (i.e. a string, not a number) then wrap this in format number().

How can i change the decimal precision and cancel the rounding of float numbers

I'm using odoo 8 and i imported an excel file which i introduced float values with 3 digits after the decimal point. After importing the data in odoo 8 as a tree view i noticed that odoo only displays 2 digits after the comma for these digits and it does the rounding however i want to keep the values as is in the excel file (without rounding and with 3 digits after the decimal point). Any idea for help please ?
You need to change the decimal precision using digits.
digits=(6, 2) specifies the precision of a float number: 6 is the total number of digits, while 2 is the number of digits after the comma. Note that it results in the number digits before the comma is a maximum 4

SAS Format in calculation

I am creating New variable as AGE.The CUTOFF value is 100 and it is divided by 12 so the value is exactly 8.3333.....But Few freshness values are 8.3333333. I have to pick the value of SEGMENT if FRESHNESS>= 100/12, but its picking AMU where freshness is 8.3333... The format of FRESHNESS is F12.9 and CUTOFF is BEST12.
data new;
set SEGMENT_AGE;
IF Freshness< CUTOFF/12 THEN AGE=AMU;
ELSE AGE=SEGMENT;
RUN;
I tried with different format making cutoff to F12.9 , still its not working
You're running into an issue of floating point precision. If a number is a repeating decimal (in binary), you may have two different values (the higher or lower - ie, 0.333333333333333333 or 0.3333333333333333333334) depending on how it was arrived at. IE:
1-(1/3) - (1/3) = 0.33333333333333333334
0+(1/3) = 0.33333333333333333333
So do not assume it is precisely equal just because it looks like it should be. Further, some numbers in decimal that are not repeating decimals are repeating in binary - 7/10 for example is 0.7 decimal but is not storable precisely in binary.
You should compare rounded numbers if you need to compare precisely; for example,
if round(freshness,0.001) < round(cutoff/12,0.001) ...
should result in your calculations matching your expectations.