decimal

What is the correct type in c\c++ to store a COM's VT_DECIMAL?

放肆的年华 提交于 2021-01-27 06:44:25
问题 I'm trying to write a wrapper to ADO. A DECIMAL is one type a COM VARIANT can be, when the VARIANT type is VT_DECIMAL . I'm trying to put it in c native data type, and keep the variable value. it seem that the correct type is long double, but I get "no suitable conversion error". For example: _variant_t v; ... if(v.vt == VT_DECIMAL) { double d = (double)v; //this works but I'm afraid can be loss of data... long double ld1 = (long double)v; //error: more then one conversion from variant to

Changing decimal separator with formula

巧了我就是萌 提交于 2021-01-21 09:50:48
问题 I work with teams from multiple countries and sometimes I receive excel files that have another decimal separator than the one I use. Is there any formula to do that? I certainly could use a macro, but a formula would be much easier because I am not the only person in my company in need of this and a macro would be too complicated for the general Joe Public. Please keep in mind that I may have multiple separators in the same number, for example, 3.000.000,00 has 2 points for the thousands and

calculate binary to decimal manually

回眸只為那壹抹淺笑 提交于 2021-01-07 06:46:28
问题 assuming I have a function to manually calculate decimal from binary number *up to four characters(binary) *assuming you can only input 0 and 1 character below code works perfectly function bin_to_dec($bin) { $bin = str_split($bin); $bin = array_reverse($bin); $i = 0; $dec = 0; foreach($bin as $values) { $ans = $values * pow(2, $i); $dec += $ans; $i++; } return $dec; } $bin = 1010 //4 $bin = 1 //1 $bin = 0 //0 assuming if you cannot use function strrev(), str_split(), array_reverse(), how

Decimal quantity step for specific product categories in WooCommerce

青春壹個敷衍的年華 提交于 2021-01-05 09:14:09
问题 I would like to adjust quantity step for specific product categories to allow decimal numbers (0.5 steps specifically). A bit like in Set quantity minimum, maximum and step at product level in Woocommerce answer but for a specific decimal step and specific product categories. Any help is welcome. 回答1: To make it work for specific product categories for decimal quantity step you don't need settings at product level… In following code you will have to set on the first function your product

Decimal quantity step for specific product categories in WooCommerce

给你一囗甜甜゛ 提交于 2021-01-05 09:13:06
问题 I would like to adjust quantity step for specific product categories to allow decimal numbers (0.5 steps specifically). A bit like in Set quantity minimum, maximum and step at product level in Woocommerce answer but for a specific decimal step and specific product categories. Any help is welcome. 回答1: To make it work for specific product categories for decimal quantity step you don't need settings at product level… In following code you will have to set on the first function your product

Adding thousand separator while printing a number [duplicate]

五迷三道 提交于 2021-01-04 02:31:04
问题 This question already has answers here : How to print number with commas as thousands separators? (27 answers) Closed 7 years ago . I don't really know the "name" for this problem, so it might be a incorrect title, but the problem is simple, if I have a number for example: number = 23543 second = 68471243 I want to it make print() like this. 23,543 68,471,243 I hope this explains enough or else add comments. Any help is appreciated! 回答1: If you only need to add comma as thousand separator and

Adding thousand separator while printing a number [duplicate]

烂漫一生 提交于 2021-01-04 02:30:40
问题 This question already has answers here : How to print number with commas as thousands separators? (27 answers) Closed 7 years ago . I don't really know the "name" for this problem, so it might be a incorrect title, but the problem is simple, if I have a number for example: number = 23543 second = 68471243 I want to it make print() like this. 23,543 68,471,243 I hope this explains enough or else add comments. Any help is appreciated! 回答1: If you only need to add comma as thousand separator and

Convert decimal hours to HH:MM:SS

倾然丶 夕夏残阳落幕 提交于 2021-01-03 03:20:11
问题 I'm looking for a way to convert decimal hours to HH:MM:SS For instance, as input: 4.927778 hours Desired output: 04:55:40 回答1: You can try something like below dh <- 4.927778 strftime(as.POSIXct(dh * 60 * 60, origin = Sys.Date(), tz = "GMT"), format = "%H:%M:%S") ## [1] "04:55:40" 回答2: You should be able to get an idea of what you need to do - a <- "4.927778 hours" a <- as.numeric(gsub(x = a,pattern = " hours", replacement = "")) h <- a%/% 1 m <- ((a%% 1)*60) %/% 1 s <- round((((a%% 1)*60) %

Convert decimal hours to HH:MM:SS

穿精又带淫゛_ 提交于 2021-01-03 03:15:39
问题 I'm looking for a way to convert decimal hours to HH:MM:SS For instance, as input: 4.927778 hours Desired output: 04:55:40 回答1: You can try something like below dh <- 4.927778 strftime(as.POSIXct(dh * 60 * 60, origin = Sys.Date(), tz = "GMT"), format = "%H:%M:%S") ## [1] "04:55:40" 回答2: You should be able to get an idea of what you need to do - a <- "4.927778 hours" a <- as.numeric(gsub(x = a,pattern = " hours", replacement = "")) h <- a%/% 1 m <- ((a%% 1)*60) %/% 1 s <- round((((a%% 1)*60) %

Convert decimal hours to HH:MM:SS

余生颓废 提交于 2021-01-03 03:14:33
问题 I'm looking for a way to convert decimal hours to HH:MM:SS For instance, as input: 4.927778 hours Desired output: 04:55:40 回答1: You can try something like below dh <- 4.927778 strftime(as.POSIXct(dh * 60 * 60, origin = Sys.Date(), tz = "GMT"), format = "%H:%M:%S") ## [1] "04:55:40" 回答2: You should be able to get an idea of what you need to do - a <- "4.927778 hours" a <- as.numeric(gsub(x = a,pattern = " hours", replacement = "")) h <- a%/% 1 m <- ((a%% 1)*60) %/% 1 s <- round((((a%% 1)*60) %