# Search:

Type: Posts; User: Habbit; Keyword(s):

Page 1 of 10 1

1. ## Thread: Best way to check for divide by 0 in C++?

by Habbit
Replies
7
Views
4,451

### Re: Best way to check for divide by 0 in C++?

Mathematically x/0 is undefined for all x including 0. What can be defined is the limit of the quotient f(x)/g(x) as x approaches some value that makes both f and g zero. However, since computers...
2. ## Thread: Best way to check for divide by 0 in C++?

by Habbit
Replies
7
Views
4,451

### Re: Best way to check for divide by 0 in C++?

Actually, floating point division by zero does not cause a crash. IEEE754 rules specify that x divided by zero is an appropriately signed infinity. This is so because you can reach a "zero" result...
3. ## Thread: segmentation fault in fwrite

by Habbit
Replies
15
Views
2,073

### [SOLVED] Re: segmentation fault in fwrite

A common solution to the problem dwhitney pointed is making the comparison the other way around, i.e. writing "NULL == (my complicated expression here)" instead of "(something) == NULL". That way, if...
4. ## Thread: [ Java ] How to initialize a 2-dimensional array as [][] ( not [3][5] ) ?

by Habbit
Replies
13
Views
927

### Re: [ Java ] How to initialize a 2-dimensional array as [][] ( not [3][5] ) ?

Can't you create an ArrayList<Object[]>? I'm not sure array types can be used as type parameters, but you can give it a try. Make sure to call toArray with the appropiate type.
5. ## Thread: need a mentor or personal trainer

by Habbit
Replies
16
Views
895

### Re: need a mentor or personal trainer

class my_class {
float parse_and_round(const char*, int);
float density_of_codepoint(const char*, int);
// Whatever
};
typedef float (my_class::* my_method)(const char*, int);

//...
6. ## Thread: Help with a simple C++ Program

by Habbit
Replies
10
Views
888

### [SOLVED] Re: Help with a simple C++ Program

"sh: Syntax error"? You know you have to compile and link C++ programs before using them, right?

\$ g++ my_source.cpp -o my_app
\$ ./my_app
7. ## Thread: need a mentor or personal trainer

by Habbit
Replies
16
Views
895

### Re: need a mentor or personal trainer

Well, Rtfm is a good mentor indeed! ;)

Seriously now, most of us are (there's no need to hide it) a bunch of computer geeks with the teaching talents of a book shut, bound, drowned in cement and...
8. ## Thread: Ip geolocating wallpaper [bash]

by Habbit
Replies
2
Views
700

### Re: Ip geolocating wallpaper [bash]

Regarding your point #3: you need to know the projection used in your map, and then you will most likely be able to find a mathematical model for that projection that you can use to transform the...
9. ## Thread: C++ Explain this: int i = *(int*)&x;

by Habbit
Replies
8
Views
1,424

### Re: C++ Explain this: int i = *(int*)&x;

By the way, C++ has more explicit cast operators called X_cast. They perform a defined operation and have known, specified ways of failing, instead of the unknown "black magic" represented by a C...
10. ## Thread: C main() function

by Habbit
Replies
12
Views
683

### Re: C main() function

In old C, functions were not always prototyped. Declaring a function as "T f();" tells the compiler that any arguments are acceptable (including no arguments at all). Acceptable calls would be f(),...
11. ## Thread: how to find characters like: " "?

by Habbit
Replies
3
Views
216

### Re: how to find characters like: " "?

Those (0x04 and 0x05) are control characters, which do not have a printable representation. Most are a relic from the teletype age, currently unused, and so you can see them sometimes doubling as...
12. ## Thread: local variables size

by Habbit
Replies
3
Views
958

### Re: local variables size

Well, a 10000x10000 double matrix would use up 8x10000x10000=8E8 bytes, which is more than half a gigabyte. Usually stack space (where local variables reside) is not that big, but orders of magnitude...
13. ## Thread: C; my attempts to free memory fail.

by Habbit
Replies
14
Views
723

### [SOLVED] Re: C; my attempts to free memory fail.

Note that free() _can_ return memory to the system, but doesn't have to. It's very possible that the implementation of malloc/free in glibc only returns memory to the system if you free a...

by Habbit
Replies
10
Views
1,738

Indeed #-o
15. ## Thread: A problem with vector.h class in c++

by Habbit
Replies
10
Views
1,738

### Re: A problem with vector.h class in c++

The problem is not 0. Zero itself (and specifically 0, not any other number) is recognized as a null pointer constant, and automagically casts to any pointer type. The problem is (most likely) that...
16. ## Thread: Intel's compiler cripples code on AMD and VIA chips

by Habbit
Replies
8
Views
602

### Re: Intel's compiler cripples code on AMD and VIA chips

The problem is not the Intel compiler not delivering the best possible optimizations for non-Intel processors, but the fact that it also failed to perform pretty generic optimizations (and sometimes...
17. ## Thread: Java Collection question<E>

by Habbit
Replies
2
Views
246

### Re: Java Collection question

Indeed, the "extends Response" puts an upper bound on the type T: it must be a subtype of Response (note that this includes Response itself). The other type of constraint available reads "T super U",...
18. ## Thread: [C++] Fun with file size

by Habbit
Replies
14
Views
1,005

### Re: [C++] Fun with file size

Code for global initialization and termination of the C++ runtime environment, plus ELF headers and (maybe) debug information might do that. Try to compile the same code (including "stdio.h" instead...
19. ## Thread: G++ How to use long long and uint64_t?

by Habbit
Replies
20
Views
38,083

### Re: G++ How to use long long and uint64_t?

Using the C99 include file <stdint.h>, which will also be part of the next C++ standard as <cstdint>, you can use the standard integer constant macros, which transform the integer constant into the...
20. ## Thread: C++ How to flush stream?

by Habbit
Replies
7
Views
3,558

### Re: C++ How to flush stream?

The "flush" operation is also available as an IO manipulator, so it can be used with the << operator:
std::cout << "mytext" << std::flush;
sleep(10);

Additionally, the "endl" manipulator is...
21. ## Thread: c++ array question

by Habbit
Replies
7
Views
369

### Re: c++ array question

First of all, you are wrong in thinking it "should not work". C++ (like C) is built for speed, and so it tries not to impose any overhead you might not want. In particular, why should the compiler...
22. ## Thread: C++: high-speed "array" access

by Habbit
Replies
13
Views
4,549

### Re: C++: high-speed "array" access

If you just want a lean-mean 2D array wrapped into a class you can use with a simple syntax, look at The C++ FAQ Lite 13.10-12. It's not the main point of the page itself, but it gives good cues on...
23. ## Thread: SOLUTION: Request for member 'Foo' in 'sFoo', which is of non-class type 'sth'

by Habbit
Replies
1
Views
162

### [SOLVED] Re: SOLUTION: Request for member 'Foo' in 'sFoo', which is of non-class type 'sth'

Actually the problem is not that you are calling some other version of the constructor, but that the line "btMap mappy();" declares a _function_ called mappy that takes no arguments and returns a...
24. ## Thread: MythTV cannot rewind/ffwd TV recordings

by Habbit
Replies
1
Views
327

### [mythbuntu] Re: MythTV cannot rewind/ffwd TV recordings

Bump, does anyone know what may be causing MythTV to act so weirdly? I'm really off my area of expertise here. Btw, the recordings work just right in xine, and so-and-so in totem (skipping works, but...
25. ## Thread: MythTV cannot rewind/ffwd TV recordings

by Habbit
Replies
1
Views
327

### [mythbuntu] MythTV cannot rewind/ffwd TV recordings

Greetings, fellow forum-dwellers. I am baffled by my newest problem with MythTV: I recently replaced my old analog TV card with a DVB-T card (Hauppage WinTV Nova-T, iIrc). I've configured it and it...
Results 1 to 25 of 250
Page 1 of 10 1