standards-compliance

Difference in display between HTML and XHTML

孤街醉人 提交于 2019-12-20 02:37:12
问题 I thought XHTML documents were supposed to be displayed with exactly the same standards compliance mode as "strict" HTML documents. However, there is a difference in how they display pre elements: in HTML documents, if the <pre> start tag is followed by a LF (or CRLF), this is ignored. Not so in XHTML. Example: a HTML file and a XHTML file that have the same content, but are rendered differently. (Or if you think it's cheating to give a HTML file and a XHTML file exactly the same content,

How universally is C99 supported?

微笑、不失礼 提交于 2019-12-17 22:33:42
问题 How universally is the C99 standard supported in today's compilers? I understand that not even GCC fully supports it. Is this right? Which features of C99 are supported more than others, i.e. which can I use to be quite sure that most compilers will understand me? 回答1: If you want to write portable C code, then I'd suggest you to write in C89 (old ANSI C standard). This standard is supported by most compilers. The Intel C Compiler has very good C99 support and it produces fast binaries.

Most efficient standard-compliant way of reinterpreting int as float

会有一股神秘感。 提交于 2019-12-17 22:22:40
问题 Assume I have guarantees that float is IEEE 754 binary32. Given a bit pattern that corresponds to a valid float, stored in std::uint32_t , how does one reinterpret it as a float in a most efficient standard compliant way? float reinterpret_as_float(std::uint32_t ui) { return /* apply sorcery to ui */; } I've got a few ways that I know/suspect/assume have some issues: Via reinterpret_cast , float reinterpret_as_float(std::uint32_t ui) { return reinterpret_cast<float&>(ui); } or equivalently

<!DOCTYPE html> and older browsers

时间秒杀一切 提交于 2019-12-17 18:40:44
问题 Does <!DOCTYPE html> trigger standards mode for older browsers as well? Saying "in all modern browsers" isn't very precise. I am especially interested in IE6. Thank you. 回答1: This is how the HTML5 doctype came into existance (in layman's terms): The guys who make the standards wanted a simpler doctype. They found out that <!DOCTYPE html> (which is as simple as it gets) does trigger standards mode in browsers. They decided to standardize it in HTML5. True story. 回答2: Yes, it does trigger

Difference between scanf() and strtol() / strtod() in parsing numbers

∥☆過路亽.° 提交于 2019-12-17 16:18:30
问题 Note: I completely reworked the question to more properly reflect what I am setting the bounty for. Please excuse any inconsistencies with already-given answers this might have created. I did not want to create a new question, as previous answers to this one might be helpful. I am working on implementing a C standard library, and am confused about one specific corner of the standard. The standard defines the number formats accepted by the scanf function family (%d, %i, %u, %o, %x) in terms of

Why does C++ allow variable length arrays that aren't dynamically allocated?

萝らか妹 提交于 2019-12-17 07:52:34
问题 I'm relatively new to C++, and from the beginning it's been drilled into me that you can't do something like int x; cin >> x; int array[x]; Instead, you must use dynamic memory. However, I recently discovered that the above will compile (though I get a -pedantic warning saying it's forbidden by ISO C++). I know that it's obviously a bad idea to do it if it's not allowed by the standard, but I previously didn't even know this was possible. My question is, why does g++ allow variable length

Does constexpr imply inline?

丶灬走出姿态 提交于 2019-12-17 06:04:21
问题 Consider the following inlined function : // Inline specifier version #include<iostream> #include<cstdlib> inline int f(const int x); inline int f(const int x) { return 2*x; } int main(int argc, char* argv[]) { return f(std::atoi(argv[1])); } and the constexpr equivalent version : // Constexpr specifier version #include<iostream> #include<cstdlib> constexpr int f(const int x); constexpr int f(const int x) { return 2*x; } int main(int argc, char* argv[]) { return f(std::atoi(argv[1])); } My

Rounding error of std::cbrt?

我的梦境 提交于 2019-12-13 09:30:47
问题 I wonder if the following should be reported as a bug in gcc implementation of standard library. For all unsigned integers i , if we compare int(std::sqrt(i)) to the actual square root of the integer, the conversion always give the good result. If we do the same with std::cbrt it's not the case : // Problem of rounding of std::cbrt for i from 0 to 100 million // i, exact cbrt(i), result of int(std::cbrt(i)) 2197, 13, 12 17576, 26, 25 24389, 29, 28 140608, 52, 51 185193, 57, 56 195112, 58, 57

Which FTP transfer modes are widely used?

那年仲夏 提交于 2019-12-12 14:31:09
问题 Reading the FTP RFC (RFC959), I notice some modes that I've never seen used, and indeed don't seem to be implemented by popular FTP software (vsftpd for example). In particular, for the STRU command, only file mode "STRU F" is commonly used, and for the MODE command, only stream mode "MODE S" is commonly used. So the question is, when following best practice for developing interoperable FTP client and server software: Is it useful to support the other STRU options (record and page)? These

Does SQL standard allows whitespace between function names and parenthesis

霸气de小男生 提交于 2019-12-12 11:38:47
问题 Checking few RDBMS I find that things like SELECT COUNT (a), SUM (b) FROM TABLE are allowed (notice space between aggregate functions and parenthesis). Could anyone provide a pointer to SQL standard itself where this is defined (any version will do)? EDIT: The above works in postgres, mysql needs set sql_mode = "IGNORE_SPACE"; as defined here (for full list of functions that are influenced with this server mode see in this ref). MS SQL is reported to accept the above. Also, it seems that the