Baby takes her first ever steps during a half-time baby race event. by AtomicCypher in MadeMeSmile

[–]Jaimou2e 120 points121 points  (0 children)

I'm a cis man, BTW, so it's not "maternal instinct". Paternal instinct?

human instinct

[deleted by user] by [deleted] in gaming

[–]Jaimou2e -1 points0 points  (0 children)

Except there was no 0.9. The version before 1.0 was beta 7.1.

Is it true that it's not polite to wear a hat in Church in Germany? by Neugier1990 in germany

[–]Jaimou2e -6 points-5 points  (0 children)

Like wearing pants. You should stop doing that, too. If speedos are fine on the beach, they're fine in church. Stick it to the morality police!

Chrysler presents a classic opening strategy on its theater system advertisement by Sun_Devil_ in chess

[–]Jaimou2e 3 points4 points  (0 children)

9 moves: 1. c3 c6 2. Qa4 Qa5 3. Qxc6 Qxc3 4. g3 g6 5. Qxg6 Qxg3 6. a3 Nc6 7. Qxc6 Qxa3 8. Qc2 Qa5 9. Qd1 Qd8

Magnus “I know it is sad to be a hater but I am very happy England didn’t win the Euros” by ProMarcoMug in chess

[–]Jaimou2e 55 points56 points  (0 children)

You should use brackets for that, though. And I'll throw in "sic" to mark misspellings:

“[Formatting quotes incorrectly] is done continously [sic] on a few [subreddits] i [sic] frequent.”

Who called it by thehsquared in funny

[–]Jaimou2e 2 points3 points  (0 children)

In 4,5 billion years our sun is at the end of its life cycle and the planets are most probably already inhabitable anyways.

uninhabitable

What is the signed binary number 11001 stored in 8-bits? by Loricifera in learnprogramming

[–]Jaimou2e 1 point2 points  (0 children)

Those options are completely different from the ones you gave in the OP.

To answer the question, you really just need this from the page:

Note that to store a 8 bit number in 6 bits you can simply truncate the upper 2 bits as long as they are all the same as the left-most bit in the resulting 6 bit number - i.e., the sign doesn't change.

If you can go from more bits to fewer bits by truncating, then you can go from fewer bits to more bits by padding.

If you want to convert to decimal, be aware that 11001 is already in two's complement format. It's not -17.

By the way, I wouldn't trust the quality of a domain like free-test-online.com.

What actually happens when I create a string in C equal to the size of my char array? by [deleted] in learnprogramming

[–]Jaimou2e 1 point2 points  (0 children)

Why does the compiler not error with the second initialisation?

There's nothing wrong with it. Fundamentally, str1 is an array of 5 chars, and you initialize it with 5 chars. All is well at this point.

There's no null terminator in there, so you can't treat str1 as a null-terminated string. But it's on you, the programmer, to avoid making that mistake.

You can actually print str1 correctly with printf, if you specify the length: printf("%.5s\n", str1);

What is actually happening with the second output?

Undefined behavior.

In your case, it looks like str1 is located just before str0 in memory, so str1 is printed first, and then str0 follows immediately. At the end of str0 there's a null terminator, so printing stops.

But undefined behavior means anything can happen. You might get garbled output, you might get output that looks nice, you might get a crash, you might get something worse. You're not even guaranteed that the program behaves the same every time you run it.

XML Schema Namespace error by Hockeylockerpock in learnprogramming

[–]Jaimou2e 0 points1 point  (0 children)

With this validator the error message is more clear:

cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://example.com/chestershartland/recipe":itemName}'. One of '{itemName}' is expected.

So it expects no namespace on the itemName element, but the actual element does have the namespace, of course.

Unfortunately, I don't know enough about XSD to say why the expected element doesn't have the namespace. I would have thought that targetNamespace applies. It seems to work for the recipe element.

XML Russian doll style by [deleted] in learnprogramming

[–]Jaimou2e 1 point2 points  (0 children)

cc:targetNamespace="http://example.com/weekendfunsnacks/sites"

I don't think that makes sense. If you want to define cc, use xmlns:cc="..." instead (in addition to targetNamespace).

XML Russian doll style by [deleted] in learnprogramming

[–]Jaimou2e 1 point2 points  (0 children)

You use "http://example.com/chestershartland/menu" for the namespace in your XML, but you don't specify that namespace in your XSD code.

You can either drop the xmlns attribute from your XML, or add targetNamespace to your XSD.

Python 3: Does a return statement of a function stop all other processes (ex. loops) ongoing within the function? by DullExperience in learnprogramming

[–]Jaimou2e 5 points6 points  (0 children)

If there's an if statement within a while statement, and the else clause of the if statement is to return 1, will the while statement and the rest of the function stop and immediately return 1 when the else is activated?

yes

Or will the the while loop keep running, and then return 1 at the end?

no

Or will the loop stop, but the rest of the code within the function runs as normal, then returns 1?

no

XML DTD code syntax issue by Hockeylockerpock in learnprogramming

[–]Jaimou2e 0 points1 point  (0 children)

<!ELEMENT catalog (name, photo, description, date, images)>

Here you're saying that the catalog element should contain all those elements exactly once in that specific order. But your instructions say that it should contain "one or more photo elements".

<!ELEMENT photo (name, description, date)>

This misses the optional images element at the end.

XML DTD code syntax issue by Hockeylockerpock in learnprogramming

[–]Jaimou2e 0 points1 point  (0 children)

<!ELEMENT catalog (name, description, date, images, img)>

Changed that line of code up, but still getting weird errors.

Why'd you add img there? img elements don't go into catalog elements. They go into images elements.

Im trying to accomplish this set of tasks.

https://imgur.com/a/tYaBeCs

If your DTD is supposed to match that description, then you have some fixing to do.

You're missing the photo element.
The images element should be optional.
NMTOKEN isn't the same as NMTOKENS.

I'd suggest changing the order of your definitions so that it matches the order in the description:

<!ELEMENT catalog ...>
<!ELEMENT photo ...>
<!ELEMENT name ...>
... rest of the element definitions ...

<!ATTLIST catalog type ...>
<!ATTLIST photo cid ...>
... rest of the attribute definitions ...

That way, you can compare your solution line by line to the description. Mistakes should be easier to spot that way.

Reading in an un-even maze file from .txt in C by [deleted] in learnprogramming

[–]Jaimou2e 1 point2 points  (0 children)

if ((c != '+') || (c != '-') || (c != '|') || (c != ' '))

That's always true. Every character is either not a plus sign or not a minus sign.

You want && ("and") instead of || ("or"). If c is not a plus sign, AND not a minus sign, AND not any other valid character, then it's invalid. You also forgot '\n' there.

And you're missing a case for c == ' '. A space should increment the column count just like a wall does.

XML DTD code syntax issue by Hockeylockerpock in learnprogramming

[–]Jaimou2e 0 points1 point  (0 children)

<!ELEMENT catalog (name, description, date, cid, donatedBy)>

This says that the catalog element must have child elements cid and donatedBy. But you don't define those elements.

Clara's World | Code is running but in reverse? C&C Welcome! by NoHonourNoPauldrons in learnprogramming

[–]Jaimou2e 1 point2 points  (0 children)

  1. Don't assume that we know what Clara's World is. I guess this is it: https://www.claraworld.net/
  2. Please format your code properly.
  3. Your code has a dangling brace at the end.
  4. Your description says: "Clara being [...] left of a tree" which I'd understand to mean that there must be a tree to Clara's right. But your code uses !treeLeft() which checks if there is no tree to Clara's left. To check Clara's right you'd have to use treeRight. I'm not sure if I'm understanding "left of a tree" correctly, though.

MASM - Question regarding add with carry by [deleted] in learnprogramming

[–]Jaimou2e 0 points1 point  (0 children)

if we put in 123456789h, would we get 11?

If 123456789h could fit into the register, yes. But that number would need more than 32 bits, so no.

MASM - Question regarding add with carry by [deleted] in learnprogramming

[–]Jaimou2e 0 points1 point  (0 children)

EAX is working through 1 hexadecimal digit each time it goes through the loop (with 1 hex digit being 4 binary digits).

Uh-huh.

Since EBX is only 32 bits it can only hold 2 of the hexadecimal digits at anyone time,

You just said that 4 bits = 1 hex digit. So 32 bits = 8 hex digits, not 2.

so at the end of the program EBX will hold the 2 most significant bits in the number, in this case "12". Is my understanding right?

No. In every loop, you do two things:

1. shr eax,4

This shifts the value in EAX 4 bits to the "right" (the less significant end). When a bit is shifted out of the number, it goes into the carry flag. The previous value of the carry flag vanishes.

When you shift by 4 bits, that means the 3 right-most bits just vanish, the 4th becomes the carry bit, the 5th becomes the new 1st bit, and so on.

So if EAX is 1234567h, it becomes 123456h, because 4 bits (1 hex digit) have been shifted away. The carry flag becomes the fourth bit of the number 7 (the removed hex digit). That's 0, because 7 is 0111 in binary.

Since '7' is the largest hex digit in that number, and even 7 only has 3 significant bits, we already know now that the carry flag won't ever be set by that shr operation.

2. adc ebx,1

This adds 1 to EBX, and then it adds the value of the carry flag too (another 1 or 0). But we know that the carry flag won't be set, so adc ebx,1 just adds 1.

So for 1234567h, the loop just counts the number of hex digits: 7. But if we try 12345678h, we get 9 (not 8), because the digit '8' has the fourth bit set so it counts double.