• Create Account

# Cornstalks

Member Since 25 Sep 2004
Offline Last Active Jul 04 2016 01:08 PM

### #5157840Why is infinite technically not a number.

Posted by on 03 June 2014 - 09:25 AM

I don't know what 1+2+3+4+...=-1/12 has to do with p-adic numbers. Care to explain?

Because using the "normal"/simple definitions of summation and integers, that summation does diverge. The natural numbers are closed over addition, and yet -1/12 is not a natural number, which breaks that closure of natural numbers. So in order to make sense of this contradiction, alternative/fancier definitions of summations and numbers must be used. Specifically, p-adic numbers, which converge for large values rather than diverge. Once you're using p-adic numbers, you're not using the natural numbers and aren't restricted to the closure of natural numbers, and so can achieve 1 + 2 + 3 + ... = -1/12.

Isn't 2-1 equivalent to 1/2, so 1/2-1 would be 1/(1/2), which would be equivalent to 2? So 1/1-1 + 1/2-1 + 1/3-1 + 1/4-1 ... = 1+2+3+4...?

Like I said, I'm not good at the math, so it's interesting why two seemingly equivalent statements aren't equivalent.
i.e. sum n where n=1..∞ != sum 1/(1/n) where n=1..∞

As others have said, you can't treat infinity like a variable and do algebra with it. You can do some things (which actually involve evaluating a limit), but there are several things one might be tempted to do with infinity that would seem valid, but in reality aren't.

But maybe I'm not understanding, as I can't see the contradiction/inequality in sum n where n=1..∞ != sum 1/(1/n) where n=1..∞.

### #5157719Why is infinite technically not a number.

Posted by on 02 June 2014 - 09:44 PM

This is in fact, not true. If you evaluate the sum of all the natural numbers (1 + 2 + 3 + 4...) it is infinitely large. To evaluate this sum to have a value of -1/12th is not really correct. =/
If you want to learn the mathematical reasoning behind why the answer is infinity, but why you could evaluate a similar looking sum to have a value of -1/12th, I suggest looking up the zeta function.If you have an interest in maths, I really recommend it, there are some surprising results and really beautiful mathematics to be found there. If you don't want to learn the maths, just take it as 1 + 2 + 3 + 4... = infinity

I'm not a mathematician, but according to wikipedia and wolframalpha, ζ(−1) = -1/12

Mats1 is actually kind of correct. The thing is that the sum of the natural numbers is indeed infinite. In order to get -1/12 you have to use a different concept of numbers, called p-adic numbers.

For the curious, this question and answer give good a good introduction to the subject.

Anyway, this is further complicated by the fact that we aren't actually talking about 1 + 2 + 3 + ... = -1/12. What we're really talking about are limits and convergence, which isn't necessarily the same (or as strict) as equality. Because it's a limit we're computing, there are more ways to show 1 + 2 + 3 + ... = -1/12 than just the zeta function. So you might say 1 + 2 + 3 + ... is infinity just as much as you might say it's -1/12.

### #5157608Function that takes unknown amount of strings, how do i vector?

Posted by on 02 June 2014 - 01:18 PM

Possible i don't have latest c++11?

I'm guessing you're using Visual Studio. VS <2013 doesn't have initializer lists.

### #5157601unresolved external symbol problem

Posted by on 02 June 2014 - 12:53 PM

### #5157583Does C++ have a squared operator?

Posted by on 02 June 2014 - 12:10 PM

I know most ppl here dont like macro, and i don't either most of the time, but i think that's a good case for one:

#define POW2(x) ((x)*(x))

or maybe an inline function if you dont like macros.

My question is why you think this is good cause for a macro? What benefit does this provide over:
```template <typename T>
T pow2(const T& x) {
return x * x;
}

// Or, if using a more "modern" C++:
template <typename T>
constexpr T pow2(const T& x) {
return x * x;
}
```

### #5157581Why is infinite technically not a number.

Posted by on 02 June 2014 - 12:04 PM

One thing that hasn't been mentioned much (besides Álvaro) is which infinity you're talking about. Not all infinities are the same. For example, there's Aleph-0* and Aleph-1**.

So when you say "is infinity a number" one valid response is "which infinity are you talking about?"

It's also important to note that in spite of us sometimes treating infinity like a number, it doesn't match our definition of number: "an arithmetical value, expressed by a word, symbol, or figure, representing a particular quantity and used in counting and making calculations and for showing order in a series or for identification." There isn't a specific, particular quantity represented by infinity.

If you just go back and look at the core definitions of number and infinity, you'll see that infinity doesn't quite match the requirements to be a number.

*Aleph-0 is the number of integers (and, interestingly, there are the same number of positive integers as there are negative and positive integers).
**Aleph-1 may or may not be the number of real numbers; we cannot prove nor disprove this, but it's important to note that Aleph-1 is greater than Aleph-0.

### #5105216Pathing by using math concepts?

Posted by on 28 October 2013 - 05:53 PM

Simply by doing: y = amplitude * sin(x / (pi / 2 * wavelength))

Set amplitude to what you want, and wavelength to what you want. Set the x position, and then just calculate y based on that equation. The pi / 2 part assumes you're using radians; if you're using degrees it's just 180 / 2.

### #5104874program doesn't exit

Posted by on 27 October 2013 - 04:22 PM

Did you try returning 0 from your window procedure when you process WM_DESTROY?

no that won't matter because when i debug it the winMain function returns but there are still some threads running so the app won't shut down.

Ummm... it does matter: "If an application processes this message, it should return zero." You should be returning zero for WM_SIZE too if you handle it yourself.

Why not just run the program in your debugger, close the window, and when it's just hanging there, pause the debugger to see where you are?

### #5104842DirectX 9 or DirectX 11 ?

Posted by on 27 October 2013 - 01:58 PM

This thread was started July 2012, then had a 4 month period of peaceful death before being necroed, then had an 11 month peaceful death before being necroed again. Just FYI.

Also, XP is not going to be supported by MS in a few months, so targeting it is... old school.

### #5102994Should my website be dedicated purely to my portfolio, or can I have other co...

Posted by on 20 October 2013 - 07:04 PM

I like the way Andrew Kim from Minimally Minimal does it. He's got a mixed blog and portfolio. Some things in his blog are clearly unrelated to his portfolio, but his blog posts are still very professional and show more about him as a whole than a straight portfolio would.

Just make sure you keep your portfolio clear and easily accessible in your site. You want to make it clear when you say "this is my portfolio" and "this is my blog". And make sure they are both professional.

### #5102874Unmaintainable code

Posted by on 20 October 2013 - 10:45 AM

My response was this: What is he talking about? It's just a blank file. I see nothing. Granted, it's thousands of lines of nothing, but I can maintain  blank lines pretty well.

**scroll around, notice I can scroll to the right, and so I scroll to the right as much as I can**

Oh.. Oh no... No no no no no. That can't be... Yup... it really is... HOLY !@#!

### #5102442Dijsktra and STL Priority Queues

Posted by on 18 October 2013 - 10:34 AM

I've tried it and it works fine, thank you! There is one more issue though, imagine this:
- Node1 is already in the queue with a shortest cost of 3
- During the graph exploration I find a new shortest path to Node1 with cost 2
- So I insert Node1 into the queue with the new cost of 2

Won't this create a duplicate entry of Node1 on the queue, where the first entry as a cost of 3 and the second entry has a cost of 2?
Is there an easy way to update the existing entry on the queue and re-sort the queue?

Yes, it will be duplicated in the priority queue. This does not cause an issue (because the lower cost one will be popped off the queue before the higher cost one, and when the higher cost one is popped off you can just check if the node is already closed and skip processing if it is). Just make sure that you aren't storing pointers in your queue (because then when you update a node, it will also update the node already in the queue, invalidating the queue's sorting).

If you don't want duplicates in your priority queue, you'll have to write your own so you can update an existing element. Priority queues are actually pretty easy to write.

### #5102421Dijsktra and STL Priority Queues

Posted by on 18 October 2013 - 09:24 AM

I typically use a std::vector and the heap functions (std::make_heap, std::sort_heap, std::push_heap, and std::pop_heap) to implement a priority queue for Dijkstra's algorithm.

This (though it could be simpler).

Do not use a std::set for Dijkstra's. It's the wrong data structure. Also, do not use a normal queue or list. The whole difference between breadth-first search (BFS) and Dijkstra's is Dijkstra's uses a priority queue while normal BFS uses a normal queue. That's the only difference (and the only difference between Dijkstra's and A* is an added heuristic).

Use a std::priority_queue.

### #5101483Behold! The compiler which compiles itself(*)

Posted by on 15 October 2013 - 12:58 AM

I seriously thought about writing a combiner script, but it honestly turns out that having everything in a monolithic file isn't all that bad. 10KLOC is large but not unmanageable, and it's actually easier to remember how to find things in a single file than you might expect. Of course, it helps that the Epoch implementation of the compiler is about 1/4 the size of the C++ implementation, so remembering things is 4 times easier to begin with ;-)

How were you doing it in C++? Were you using Flex/Lex and Yacc/Bison at all?

The grammar should be deterministic-context-free. I think. I'm honestly not strong enough in parser theory to prove it for sure, but that feels about right. The parser itself is just a DFA written in classic recursive-descent style, so based on my understanding of the parser/grammar categories, the grammar is DCF. I could be utterly wrong, though.

Cool. Sounds context-free to me. I'm working on an implementation of parsing with derivatives in C++ for my undergraduate thesis, and assuming I actually finish it maybe I can use Epoch's grammar (or a subset of it) as a demo and case study.

All very cool. I'll see if I have more questions that come up during the week.

### #5101045goto considered harmful within global macros

Posted by on 13 October 2013 - 09:51 AM

I'm 100% surprised a velociraptor attack did not ensue. That macro only saves you from typing 7 keystrokes too... totally not worth using it IMO. And I hate macros like that for debugging and stepping through code.

Also, condition really should've been in parentheses (like in l0calh05t's post), because other wise things like CheckSuccess(false || true) would've resulted in madness.

PARTNERS