<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.explainxkcd.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dondiego87</id>
		<title>explain xkcd - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://www.explainxkcd.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dondiego87"/>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php/Special:Contributions/Dondiego87"/>
		<updated>2026-05-22T22:10:52Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=1537:_Types&amp;diff=95366</id>
		<title>1537: Types</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=1537:_Types&amp;diff=95366"/>
				<updated>2015-06-12T14:47:55Z</updated>
		
		<summary type="html">&lt;p&gt;Dondiego87: /* Explanation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{comic&lt;br /&gt;
| number    = 1537&lt;br /&gt;
| date      = June 12, 2015&lt;br /&gt;
| title     = Types&lt;br /&gt;
| image     = types.png&lt;br /&gt;
| titletext = colors.rgb(&amp;quot;blue&amp;quot;) yields &amp;quot;#0000FF&amp;quot;. colors.rgb(&amp;quot;yellowish blue&amp;quot;) yields NaN. colors.sort() yields &amp;quot;rainbow&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Explanation==&lt;br /&gt;
{{incomplete|Title text not explained. More details before the list.}}&lt;br /&gt;
&lt;br /&gt;
This comic is a series of programming jokes about a ridiculous new programming language, perhaps inspired by [https://www.destroyallsoftware.com/talks/wat Gary Bernhardt's CodeMash 2012 lightning talk] on Javascript's unpredictable typing. The (highly technical) audience is unable to correctly guess the results of adding various Javascript types, and roars with laughter when they're revealed.&lt;br /&gt;
&lt;br /&gt;
Most regular programming languages distinguish a number of types, e.g. integers , strings, lists,... All of which have different behaviours. The operation &amp;quot;+&amp;quot; is conventionally defined over more than one of these types. Applied to two integers, it returns their addition, but applied to two strings it concatenates them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;gt; 2 + 3&lt;br /&gt;
&lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
&amp;gt; &amp;quot;123&amp;quot; + &amp;quot;abc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;123abc&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While these behaviours are standard, conventional, and intuitive, there is a huge amount of variation among programming languages when you apply an operation like &amp;quot;+&amp;quot; to different types. One logical approach is to always return an error in all cases of type mixing, but it is often practical to allow some case mixing, since it can hugely simplify an operation. Variation and lack of a clearly more intuitive behaviour leads some languages to have weird results when you mix types.&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;2 + &amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; uses the &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; operator on a number and a string. In a normal language, this would result either the number &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; (addition), or &amp;lt;code&amp;gt;&amp;quot;22&amp;quot;&amp;lt;/code&amp;gt; (string concatenation); however, the new language converts the string to an integer, adds them to produce &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; and converts back to a string.&lt;br /&gt;
# &amp;lt;code&amp;gt;&amp;quot;2&amp;quot; + []&amp;lt;/code&amp;gt; adds a string to an array (a list), this time. This first inexplicably converts the string to a number again, and then it literally adds the number to the list by appending it (this would make sense if it was &amp;lt;code&amp;gt;[] + 2&amp;lt;/code&amp;gt;, but usually not the other way around). And then the result is converted to a string again.&lt;br /&gt;
# &amp;lt;code&amp;gt;(2/0)&amp;lt;/code&amp;gt; divides &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; by &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; and quite reasonably results in &amp;lt;code&amp;gt;NaN&amp;lt;/code&amp;gt; (not a number).&lt;br /&gt;
# &amp;lt;code&amp;gt;(2/0)+2&amp;lt;/code&amp;gt; adds &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;NaN&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; is &amp;quot;added&amp;quot; to the string &amp;lt;code&amp;gt;&amp;quot;NaN&amp;quot;&amp;lt;/code&amp;gt; (again, the number is converted to a string for apparently no reason), which produces &amp;lt;code&amp;gt;&amp;quot;NaP&amp;quot;&amp;lt;/code&amp;gt;, as if &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; was added to &amp;lt;code&amp;gt;&amp;quot;N&amp;quot;&amp;lt;/code&amp;gt; to produce &amp;lt;code&amp;gt;&amp;quot;P&amp;quot;&amp;lt;/code&amp;gt; (as per alphabetical order or ASCII encoding; &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;01001110&amp;lt;/code&amp;gt;, and adding 2 to this results in &amp;lt;code&amp;gt;01010000&amp;lt;/code&amp;gt; which is &amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &amp;lt;code&amp;gt;&amp;quot;&amp;quot;+&amp;quot;&amp;quot;&amp;lt;/code&amp;gt; looks like it is concatenating (adding) an empty string to another empty string, which should produce an empty string. However, the entire thing is treated as one string (with the start quote being the first one and the end quote being the very last one), which produces the egregious '&amp;lt;code&amp;gt;&amp;quot;+&amp;quot;&amp;lt;/code&amp;gt;'.&lt;br /&gt;
# &amp;lt;code&amp;gt;[1,2,3]+2&amp;lt;/code&amp;gt; seems to test whether it's sound to append &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; to the list &amp;lt;code&amp;gt;[1,2,3]&amp;lt;/code&amp;gt;, and concludes that it doesn't fit the pattern, returning the boolean value &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. It could conceivably also be the result of an attempt to add &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; to the ''set'' &amp;lt;code&amp;gt;[1,2,3]&amp;lt;/code&amp;gt;, which already contains that element (although &amp;lt;code&amp;gt;{1,2,3}&amp;lt;/code&amp;gt; would be a more common notation for sets).&lt;br /&gt;
# &amp;lt;code&amp;gt;[1,2,3]+4&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; for much the same reason.&lt;br /&gt;
# &amp;lt;code&amp;gt;2/(2-(3/2+1/2))&amp;lt;/code&amp;gt; is a floating point joke. Floating point numbers are notoriously imprecise. With precise mathematics, &amp;lt;code&amp;gt;(3/2+1/2)&amp;lt;/code&amp;gt; would be exactly 2, hence the entire thing would evaluate to &amp;lt;code&amp;gt;2/0&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;NaN&amp;lt;/code&amp;gt; in Randall's new language. However, the result of &amp;lt;code&amp;gt;(3/2+1/2)&amp;lt;/code&amp;gt; is &amp;quot;just slightly off,&amp;quot; which makes the result &amp;quot;just slightly off&amp;quot; of &amp;lt;code&amp;gt;NaN&amp;lt;/code&amp;gt; (which would be ridiculous in a real language). The ironic thing is that fractions with 2 in the denominator are ''not'' the kind of numbers that typically suffer from floating point impreciseness. Additionally, if there was indeed a rounding error, the actual calculation becomes something like &amp;lt;code&amp;gt;2/0.0000000000000013&amp;lt;/code&amp;gt;, which should not return a &amp;lt;code&amp;gt;NaN&amp;lt;/code&amp;gt; since it is not division by zero.&lt;br /&gt;
# &amp;lt;code&amp;gt;range(&amp;quot; &amp;quot;)&amp;lt;/code&amp;gt; normally wouldn't make any sense. However, the new language appears to interpret it as ASCII, and in the ASCII table, character #32 is space, #33 is &amp;lt;code&amp;gt;!&amp;lt;/code&amp;gt;, and #34 is &amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;. So, instead of interpreting &amp;lt;code&amp;gt;&amp;quot; &amp;quot;&amp;lt;/code&amp;gt; as a string, it seems to be interpreted as &amp;lt;code&amp;gt;34, 32, 34&amp;lt;/code&amp;gt; (in ASCII), and then &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt; appears to transform this into &amp;lt;code&amp;gt;34, 33, 32, 33, 34&amp;lt;/code&amp;gt; (the &amp;quot;ranges&amp;quot; between the numbers), which, interpreted as ASCII, becomes &amp;lt;code&amp;gt;['&amp;quot;', '!', ' ', '!', '&amp;quot;']&amp;lt;/code&amp;gt;.&lt;br /&gt;
# &amp;lt;code&amp;gt;+2&amp;lt;/code&amp;gt; appears to be applying a unary &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; to the number &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;, which should just be &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;. However, the code is adding  &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; to the line number &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; in this context. &lt;br /&gt;
# &amp;lt;code&amp;gt;2+2&amp;lt;/code&amp;gt; would normally be &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;. However, the interpreter takes this instruction to mean to add the value 2 to the literal value of &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;, making it &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; and then reports that the work is &amp;quot;Done&amp;quot;.  This can be seen in the subsequent lines where all &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;s are replaced by &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;s.  This could be a reference to languages like Fortran where literals were able to be assigned new values.&lt;br /&gt;
# &amp;lt;code&amp;gt;range(1,5)&amp;lt;/code&amp;gt; would normally return &amp;lt;code&amp;gt;[1, 2, 3, 4, 5]&amp;lt;/code&amp;gt;. However, since the value of &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; has been changed to &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;, it returns &amp;lt;code&amp;gt;[1, 4, 3, 4, 5]&amp;lt;/code&amp;gt;, and this even affects the line number (which is 14 instead of 12).         &lt;br /&gt;
# &amp;lt;code&amp;gt;floor(10.5)&amp;lt;/code&amp;gt; should return &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; (the &amp;quot;floor&amp;quot; of a decimal number is that number rounded down). However, it instead returns {{w|ASCII art}} of the number on a &amp;quot;floor.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The title text contains three further examples relating to color. &amp;lt;code&amp;gt;color.rgb(&amp;quot;blue&amp;quot;)&amp;lt;/code&amp;gt; returns the hexadecimal code for pure blue (as would be used in HTML, for example), which is how a real programming language might work. The lookup for &amp;quot;yellowish blue&amp;quot; returns &amp;quot;NaN&amp;quot; (Not a Number) again, which makes sense at one level because there is no such color as &amp;quot;yellowish blue&amp;quot; (yellow and blue are complements: mix them and you get white or black depending on whether you are using additive or subtractive colors). However a more typical result would have been a failure indicating that the color database does not include the name, in the same way that a typo such as &amp;quot;bluw&amp;quot; would. Similarly sorting the colors would normally produce some defined ordering, such as alphabetical, but in this language it generates the string &amp;quot;rainbow&amp;quot;. It seems that Randall's new language understands color theory in an unusually deep way.&lt;br /&gt;
&lt;br /&gt;
==Transcript==&lt;br /&gt;
My new language is great, but it has a few quirks regarding type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 [1]&amp;gt; 2+&amp;quot;2&amp;quot;&lt;br /&gt;
   =&amp;gt; &amp;quot;4&amp;quot;&lt;br /&gt;
 [2]&amp;gt; &amp;quot;2&amp;quot;+[]&lt;br /&gt;
   =&amp;gt; &amp;quot;[2]&amp;quot;&lt;br /&gt;
 [3]&amp;gt; (2/0)&lt;br /&gt;
   =&amp;gt; NaN&lt;br /&gt;
 [4]&amp;gt; (2/0)+2&lt;br /&gt;
   =&amp;gt; NaP&lt;br /&gt;
 [5]&amp;gt; &amp;quot;&amp;quot;+&amp;quot;&amp;quot;&lt;br /&gt;
   =&amp;gt; '&amp;quot;+&amp;quot;'&lt;br /&gt;
 [6]&amp;gt; [1,2,3]+2&lt;br /&gt;
   =&amp;gt; FALSE&lt;br /&gt;
 [7]&amp;gt; [1,2,3]+4&lt;br /&gt;
   =&amp;gt; TRUE&lt;br /&gt;
 [8]&amp;gt; 2/(2-(3/2+1/2))&lt;br /&gt;
   =&amp;gt; NaN.0000000000000013&lt;br /&gt;
 [9]&amp;gt; range(&amp;quot; &amp;quot;)&lt;br /&gt;
   =&amp;gt; ('&amp;quot;','!',&amp;quot; &amp;quot;,&amp;quot;!&amp;quot;,'&amp;quot;')&lt;br /&gt;
[10]&amp;gt; +2&lt;br /&gt;
   =&amp;gt; 12&lt;br /&gt;
[11]&amp;gt; 2+2&lt;br /&gt;
   =&amp;gt; DONE&lt;br /&gt;
[14]&amp;gt; RANGE(1,5)&lt;br /&gt;
   =&amp;gt; (1,4,3,4,5)&lt;br /&gt;
[13]&amp;gt; FLOOR(10.5)&lt;br /&gt;
   =&amp;gt; |&lt;br /&gt;
   =&amp;gt; |&lt;br /&gt;
   =&amp;gt; |&lt;br /&gt;
   =&amp;gt; |&lt;br /&gt;
   =&amp;gt; |___10.5___&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The alt text for the image starts out with colors.rgb(&amp;quot;blue&amp;quot;) yields &amp;quot;#0000FF&amp;quot;. Again, it just took a string, turned it into a variable, and made it a string again. However, the .rgb function shouldn't be returning a hex code for the color!&lt;br /&gt;
It then transitions into colors.rgb(&amp;quot;yellowish blue&amp;quot;) yields &amp;quot;NaN&amp;quot;. Seeing how it returned a hex code for the last one, attempting to get the RGB value of an [https://en.wikipedia.org/wiki/Impossible_color impossible color] would predictably cause it to return NaN.&lt;br /&gt;
Finally, colors.sort() yields &amp;quot;rainbow&amp;quot;. It just got stuffed through a prism, which sorted the colors into a rainbow!&lt;br /&gt;
{{comic discussion}}&lt;/div&gt;</summary>
		<author><name>Dondiego87</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=1522:_Astronomy&amp;diff=92941</id>
		<title>1522: Astronomy</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=1522:_Astronomy&amp;diff=92941"/>
				<updated>2015-05-09T16:28:28Z</updated>
		
		<summary type="html">&lt;p&gt;Dondiego87: /* Spellin/grammar */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{comic&lt;br /&gt;
| number    = 1522&lt;br /&gt;
| date      = May 8, 2015&lt;br /&gt;
| title     = Astronomy&lt;br /&gt;
| image     = astronomy.png&lt;br /&gt;
| titletext = Astrobiology is held back by the fact that we're all too nervous to try to balance on the ladder while holding an expensive microscope.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Explanation==&lt;br /&gt;
{{incomplete|Clarify the optical principles re focal length, magnification etc (see discussion).}}&lt;br /&gt;
&lt;br /&gt;
For many ordinary objects, one can achieve a better view in two ways: (#1) by looking at the object from a distance through a {{w|telescope}} as is the typical method in &amp;quot;'''{{w|Astronomy}}'''&amp;quot;, or (#2) by approaching the object and looking at it through a {{w|microscope}} as is the typical method in {{w|biology}}. (A {{w|magnifying glass}} is a simple type of microscope.)  Microscopes and magnifying glasses typically have very short {{w|Optical resolution|resolving distances}}, anywhere between a few millimeters to a tenth of a meter, so approach #2 is effective only in the case where you can get very close to the object in question (as in biology).&lt;br /&gt;
&lt;br /&gt;
In the comic, the objects being viewed by Megan could be {{w|stars}}, {{w|galaxies}} and the {{w|planets}} of our {{w|Solar System}}.  [[Megan]] takes approach #1, looking at them through a telescope.  [[Beret Guy]] attempts approach #2, using a step-ladder to get close to the stars, and then looking at them through his simple hand-held magnifying glass.  This approach could be successful only if the stars were a few meters away, so that the ladder would take him within a few centimeters of the study object. In fact the visible stars are several {{w|light years}} away (typically 18-20 orders of magnitude further away) and getting two meters up on a ladder won't make any difference. &lt;br /&gt;
&lt;br /&gt;
Usually, however, Beret Guy has unusually strange powers over time and space, so it's quite possible that his method would yield similar or even better results than Megan's approach.  Given his naïveté, it's also possible he just doesn't realize they should look any different. His naïveté of astronomy is demonstrated in [[811: Starlight]]. &lt;br /&gt;
&lt;br /&gt;
The history of astronomy is filled with drastic misunderstanding of distances to celestial bodies, even up to the present day (a topic Randall has already covered in [[1342: Ancient Stars]].) Thus, the comic could be in reference to the general overestimation of distances, albeit taken to the opposite extreme.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the comic could also be a reference to the fact that space-based telescopes are much smaller than ground-based telescopes: for example, the primary mirrors of the {{w|Hubble Space Telescope}} are 2.4 m vs. the earth based {{w|W. M. Keck Observatory}} with mirrors of 10 m.&lt;br /&gt;
&lt;br /&gt;
The title text assumes (for comic effect) that the only thing wrong with Beret Guy's strategy is the instability of the ladder endangering the expensive microscopes used by biologists for {{w|Astrobiology}}. Astrobiology is the study of life (or the possibility thereof) elsewhere in the universe, and here it would be either the planets and moons in our Solar System or {{w|exoplanets}} they needed to look at. This is the second comic related to studying exoplanets in two weeks, the first being [[1517: Spectroscopy]] (see more references there). &lt;br /&gt;
&lt;br /&gt;
Since we cannot go there, they do, of course, not use any microscopes in the direct studies. However, one typical magnifier in biology is the {{w|electron microscope}}, used to study {{w|microbiology}}, and they cost a lot and are very heavy. They are therefore implausible to carry up a ladder and it could possibly become very expensive if you did try it anyway.&lt;br /&gt;
&lt;br /&gt;
It might be interesting to note that a lot of developments in &amp;quot;terrestrial&amp;quot; biology (called biology here on Earth), were made by the use of a simple microscope (similar to a magnifying lens), so Beret Guy's approach might be an attempt to build on that.&lt;br /&gt;
&lt;br /&gt;
==Transcript==&lt;br /&gt;
&lt;br /&gt;
:[In front of a starry black sky, Megan looks at the stars through a telescope about twice her size, touching it at the base. She remains in the exact same position through all four panels.]&lt;br /&gt;
&lt;br /&gt;
:[Beret Guy enters the panel holding a ladder and a magnifying glass]&lt;br /&gt;
&lt;br /&gt;
:[Beret Guy places the ladder next to Megan and her telescope. The ladder is stands like a triangle, is slightly larger than Megan, but smaller than the telescope]&lt;br /&gt;
&lt;br /&gt;
:[Beret guy climbs to the top of the ladder, and looks at the stars through a magnifying glass]&lt;br /&gt;
&lt;br /&gt;
{{comic discussion}}&lt;br /&gt;
&amp;lt;!-- Include any categories below this line. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Comics with inverted brightness]]&lt;br /&gt;
[[Category:Comics featuring Megan]]&lt;br /&gt;
[[Category:Comics featuring Beret Guy]]&lt;br /&gt;
[[Category:Science]]&lt;br /&gt;
[[Category:Astronomy]]&lt;br /&gt;
[[Category:Biology]]&lt;/div&gt;</summary>
		<author><name>Dondiego87</name></author>	</entry>

	</feed>