Posts

Showing posts with the label standards

Can a conversion from double to int be written in portable C

Can a conversion from double to int be written in portable C I need to write function like double_to_int(double val, int *err) which would covert double val to integer when it's possible; otherwise report an error (NAN/INFs/OUT_OF_RANGE). double_to_int(double val, int *err) so pseudo code implementation would look like: if isnan(val): err = ERR_NAN return 0 if val < MAX_INT: err = ERR_MINUS_INF return MIN_INT if ... return (int)val There are at least two similar questions on SO: in this answer it's solved in enough clean way, though it's C++ solution - in C we do not have portable digits for signed int. In this answer, it's explained why we cannot just check (val > INT_MAX || val < INT_MIN) . (val > INT_MAX || val < INT_MIN) So the only possible clean way i see is to use floating point environment, but it's stated as implementation-defined feature. So my question: is there any way to implement double_to_int function in cross-platform...

google big query standard SQL

google big query standard SQL I am on Google big query using standard SQL and I am stuck because of the following sql. the name of the error is : Values referenced in UNNEST must be arrays. UNNEST contains expression of type STRING at [1:1155] SELECT COUNT(DISTINCT user_first_touch_timestamp) as count, event_date as dt FROM `analytics_173262434.events_20*` AS t CROSS JOIN UNNEST(event_date) AS event WHERE parse_date('%y%m%d', _table_suffix) between DATE_sub (current_date(), interval 23 day) and DATE_sub (current_date(), interval 1 day) GROUP BY event_date By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.