last day (39 days later) » 

12:46 AM
56
A: Why are the fast integer types faster than the other integer types?

eerorikaImagine a CPU that performs only 64 bit arithmetic operations. Now imagine how you would implement an unsigned 8 bit addition on such CPU. It would necessarily involve more than one operation to get the right result. On such CPU, 64 bit operations are faster than operations on other integer width...

 
So, you'd be basically declaring 64 bit variables no matter what Y is?
 
@machine_1 If you declare a Xint_fastY_t variable on a system where 64 bit operations are faster than narrower ones then yes, you are declaring a 64 bit variable regardless of Y.
 
That table is great
 
Generally, cache space isn't very relevant since you're only declaring a few local variables which hopefully fit in registers (but which may spill to the stack)
 
the list doesn't represent all compiler implementations. For example on x86 mingw defines the fast types as exactly the same width as the normal types. Same to iOS/macOS and to some extent Windows
 
12:46 AM
@LightnessRacesBY-SA3.0 I used to use Asciio to draw ASCII diagrams, do you use something more advanced or is it all handmade?
 
@phuclv Thanks for confirming. I already stated as much, but I've now reworded to be more assertive.
 
@eerorika there are many tools to draw such a table automatically. See Create ASCII art tables. There are also tools to draw arbitrary shapes
 
Linux GCC on x86-64 really defines int_fast16_t and int_fast32_t as 64-bit types? Are you certain about that column in the table? If so, that's a pessimization, and likely a bug in the implementation... I can't think of any reason why it would be doing that. Both should be 32-bit types. 64-bit values are absolutely no faster to work with on x86-64 than 32-bit values (unlike 16-bit values, which are slower on all x86), and there is a minor penalty coming from the REX prefix to encode long-mode instructions (not to mention memory concerns related to storing values twice as long as required).
 
@CodyGray it's indeed a bug in glibc github.com/bminor/glibc/blob/…
 
@eerorika So, the bare concept is: if an implementation and architecture do not support fast narrow integer type processing and it is f.e. a 64-bit architecture, when declaring a variable of the specified fast integer type group, the implementation may convert this type, f.e. the type of int_fast8_t with 8 bits, internally and implicitly to int_fast64_t with 64-bit to have better compatibility. Is that right? And: Which unit decides whether the conversion to a 64-bit integer should be done or not?
 
12:46 AM
@pipe Copy and pasting box drawing characters from Wikipedia my friend 🤣
@phuclv Of course it doesn't
 
Does the standard say what exactly the "fast" type are supposed to be fast at? Bit operations (& | ^ << >>)? Arithmetic (+ - * /)? Memory loads/stores?
 
@dan04 Unfortunately not, the both standards do not say more about those types than the above quoted section of ISO/IEC 9899:2018 (C18) . In fact, ISO/IEC 14882:2017 (C++17) does not even has a dedicated explanation/section for it, like the one quoted from C18. Only the types itself appear in ISO/IEC 14882:2017 (C++17) as part of <cstdint> in Section 21.4.1.
 
@LightnessRacesBY-SA3.0 why not? There's no reason to use int64_t for int_fast16_t
 
@LightnessRacesBY-SA3.0 no, the current version of the table isn't really great, unfortunately.
 
@Ruslan :O Chrome? Normal scaling? These characters should be fixed-width (particularly in a fixed-width font); that is the whole point of them. Very dodgy rendering there. In fact the kerning throughout that screenshot looks "off" (particularly in the comment). We should try to find the cause and report a bug to someone!
@phuclv Agreed; I was referring to your statement "the list doesn't represent all compiler implementations"
@Ruslan BTW for the record my comment referred to the original table before I added the box-drawing chars :P
 
12:46 AM
@LightnessRacesBY-SA3.0 in my Linux, the table is rendered fine on chrome and ff, but on android it is broken in both.
 
@eerorika Interesting (and repro'd). I'm loath to undo the formatting for one platform but won't be offended if you feel otherwise. Meanwhile I'm going to look into this for reporting to the Chrome folks (or whoever turns out to be at fault!)
@eerorika Appaz it's this though I don't quite understand how the glyphs render at all if the fonts don't have them. Probably falling back on a non-mono font I guess
cc @Ruslan (also see edit)
 
@LightnessRacesBY-SA3.0 It seems that the table became more prominence than its actual content. God bless the table.
 
@RobertS-ReinstateMonica May the table bless us and our children
And yes you're right. Basic characters used for decades have caused a kerfuffle because modern technology is full of oversights. IRONY This is seriously why we can't have nice things...
 
@eerorika Is it right what I have commented before? And which unit decides upon whether the type is converted or not?
 
@RobertS-ReinstateMonica I don't understand what you mean by "conversion". Xint_fastY_t are simply type names that refer to some integer type. Y is the minimum required bit width of the type. In other words, the type may be wider. The "unit" that decides which integer type is named by the alias is the implementation of the language. The reasons for choosing the alias is also largely for the implementer to decide since "usually fastest" is not a rigorous specification. The rule quoted in the question is all that is specified about it.
 
12:46 AM
@eerorika With conversion I mean, If I have f.e. a variable of type int_fast8_t with 8 bit or more (dependent of the implementation) and also I have a 64-bit CPU, which do not support fast narrow type processing, as you stated. Isn´t there happen a conversion of that type from 8 bits (or more) to 64 bits for better compatibility as you said? How is a variable of int_fast8_t then becoming a 64-bit value for better processing (if it is getting adjusted)?
 
@RobertS-ReinstateMonica There is no conversion here. A conversion happens when you use a cast, or have a subexpression in context where the type is other than is expected by the context (implicit conversion). How is a variable of int_fast8_t then becoming a 64-bit value? int_fast8_t could be defined like this for example: using int_fast8_t = int64_t;
 
@eerorika Let me redefine what my concern is: How is the potential speed improvement done by the type of int_fast8_t on a 64-bit CPU, which do not support fast narrow type processing? Why is int_fast8_t faster than f.e. int_least8_t?
 
@RobertS-ReinstateMonica The premise is that we have a language implementation where 8 bit and 64 bit types are defined. On such implementation int_least8_t would be 8 bit type as specified. The other premise is that 64 bit arithmetic in that implementation is faster. int_fast8_t is made faster by choosing the 64 bit type instead of the 8 bit type.
 
@LightnessRacesBY-SA3.0 for the record, I've found why my boxes looked wrong (on desktop Chromium & Firefox): apparently, Consolas is not too complete a font, and for some reason it was chosen as the default font for Monospace name for some reason. After I removed Consolas, the table looks OK.
 
@Ruslan Interesting. Consolas is the font chosen by SE for monospaced blocks, and it works fine for me here on Win10. However, from Wikipedia: "In version 5.22 (included with Windows 7), support for Greek Extended, Combining Diacritical Marks For Symbols, Number Forms, Arrows, Box Drawing, Geometric Shapes was added" Perhaps it's time for you to update your OS beyond XP? ;)
 
12:46 AM
@LightnessRacesBY-SA3.0 well my OS is LFS, and I copied this font from MSOffice 2007 in July 2008 to display .docx files well in OpenOffice. Yeah, it might have been improved since, but removing is now the easiest option.
 
@LightnessRacesBY-SA3.0 I don't know for sure, but my guess is that when a font doesn't have a symbol, then the renderer uses another font as a fall back (but only for the missing symbols). This is a problem for monospace fonts if the fallback has different width, but works fine when widths happen to match (or when the original monospace font has the necessary symbols).
 
@eerorika yeah, I can tell, because after I removed the Consolas' files (not having restarted Chromium), the table here lost alphanumeric characters and punctuation, but retained the pile of box-drawing lines (which presumably come from another font).
 
@Ruslan Hehe, that explains it.
@eerorika I believe that's at play yeah
 
 
10 hours later…
10:25 AM
@phuclv Is it really a bug? From stackoverflow.com/a/36961593/1447290: "The inconsistency between the sizes of int_fast32_t types when using the x32 and x86-64 ABIs is probably best justified by the fact that pointers are 64 bits wide. Whenever a 32-bit integer is added to a pointer it would need to be extended, making this a much more likely occurrence when using the x86-64 ABI."
 
@eerorika Sorry, I´d confused it a little and did not focused the table right. I mean of course, when I declare a variable of type int_fast16_t or int_fast_32_t on a x86-64 architecture, how and where (from which environment/unit) this "conversion" from the 16 bit or 32 bit value of int_fast16_t or int_fast_32_t to a 64 bit integer value is done?, given the premises you stated.
@eerorika Does a part of the execution environment (CPU,Operation system) or a part of the translation environment (compiler,linker,parser) decides about and made this "conversion" done? Where/from which part the "conversion to a 64 bit value" get executed?
 
11:06 AM
@RobertS-ReinstateMonica When you write int_fast16_t on x86-64 it is the same as writing int64_t. There is no "conversion".
 
@HBv6 yes I consider it's a bug. It's very rare for people to use [u]int_fastX_t for pointer arithmetic so the point regarding adding the value with the pointer doesn't make sense. Most probably they'll be used for temporary numeric variables. Other implementations still use int32_t for int_fast16_t on x86-64
 
11:38 AM
@user253751 How does the 16 bit value turn to a 64 bit value then? I refer to the term "conversion" in the meaning of turn a value from 16 bit to 64 bit. Or is there not happen something like a "conversion" and the compiler automatically allocates 64 bit for int_fast16_t?
@user253751 How does the compiler "know" that the he needs to switch the size of the allocated memory for int_fast16_t to 64 bit?
 
11:59 AM
@RobertS-ReinstateMonica The same way it gets turned into a 64-bit value if you write int64_t x = (some 16-bit value);. Let me repeat for emphasis: When you write int_fast16_t on x86-64 it is the same as writing int64_t.
How does the compiler know that? It's hard-coded somewhere. Imagine that the compiler contains some code like this: `if(platform == "x86-64") types["int_fast16_t"] = types["int64_t"];` . Or it might be in the standard library:

#ifdef platform_is_x86_64
typedef int64_t int_fast16_t;
#endif

(I think the second way is how it actually works in real implementations)
 
 
6 hours later…
6:17 PM
@RobertS-ReinstateMonica How does the 16 bit value turn to a 64 bit value then? I What 16 bit value? If int_fast16_t is a 64 bit type then there is no 16 bit value involved at any point.
@RobertS-ReinstateMonica Does a part of the execution environment ... or a part of the translation environment ... decides about and made this "conversion" done? Firstly, there is no "conversion". There is just a decision on what the type is. The standard doesn't specify this, but in practice, the execution environment cannot make changes to types because that would break the ABI. These integer types are defined in the C standard library headers.
 

  last day (39 days later) »