Tuesday, February 23, 2016
Sayre's Law
Here's something I read about recently, seems to apply pretty universally. I love it when little bits of wisdom like this are declared "such and such's law", "xyz's paradigm", "joe's theory of blank". I don't know why I find it funny.
Wednesday, February 10, 2016
PNG's and DPI's
PNG's are a web image format, and as such try to be independent of the device dpi so you can set the resolution and image size in your css or let the browser handle it. However, we use pngs for some desktop applications. Because of inconsistent dpi settings on different pngs we had some weird behavior where wpf was blowing up our save icons, but not our open file icons. The result in wpf was to set the width, height, and stretch attributes to our image element manually, as well as the SnapsToPixels to true for antialiasing (though at that image size I couldn't see the difference).
To be sure the png's had different dpi's and that was the problem, I had to install gimp, open the png, look at the image properties and the resolution. It would have been nice if this was just in the details tab of the properties window of the image, but if I'm right that png's don't worry about dpi it would make sense that dpi is excluded there.
Friday, February 5, 2016
My Favorite Math Joke!
A farmer has 100 ft of fencing and wants to enclose as large an area as possible, so he does the obvious thing, and hires an engineer, a physicist, and a mathematician to consult him. The engineer quickly pens in a square with the 100 ft and says voila! The physicist, knowing he can optimize this, goes to the blackboard and finds that a circle would enclose a larger area. The mathematician, after much deep thought, pulls out two feet of fencing, wraps it around his waist, and yells "I declare myself to be on the outside"!
Sunday, January 31, 2016
Euclidean Algorithm for GCD
The Euclidean algorithm is a cool little way to find the GCD of two integers.
Say you have 46 and 90...
Then 95 = 46 * 2 + 3
And 46 = 3 * 15 + 1
3 = 1 * 3 + 0
so the GCD of 95 and 46 is 1. Maybe not the best example, but I'm hungover so you can google it.
Say you have 46 and 90...
Then 95 = 46 * 2 + 3
And 46 = 3 * 15 + 1
3 = 1 * 3 + 0
so the GCD of 95 and 46 is 1. Maybe not the best example, but I'm hungover so you can google it.
Friday, January 29, 2016
Memory And Hex
As you may know I'm taking a class in C and C++ this semester (Spring of 2016) and have found C to be the best language ever (revised 2017: it's great and all, but not THIS great). It's really fun because of it's simplicity, the lack of functionality and user interface makes it easy and demanding of creativity.
I just started reading up on pointers and memory addresses when I got curious about just how memory addresses are stored in pointers. Try compiling and running the simple function below to see how memory addresses are stored as hex values.
I just started reading up on pointers and memory addresses when I got curious about just how memory addresses are stored in pointers. Try compiling and running the simple function below to see how memory addresses are stored as hex values.
Monday, January 25, 2016
Probably Handy
Since I'm taking a class in C now I think the table below that I found here will come in useful at some point...
| Precedence | Operator | Description | Associativity |
|---|---|---|---|
| 1 | ++ -- | Suffix/postfix increment and decrement | Left-to-right |
() | Function call | ||
[] | Array subscripting | ||
. | Structure and union member access | ||
-> | Structure and union member access through pointer | ||
(type){list} | Compound literal(C99) | ||
| 2 | ++ -- | Prefix increment and decrement | Right-to-left |
+ - | Unary plus and minus | ||
! ~ | Logical NOT and bitwise NOT | ||
(type) | Type cast | ||
* | Indirection (dereference) | ||
& | Address-of | ||
sizeof | Size-of | ||
_Alignof | Alignment requirement(C11) | ||
| 3 | * / % | Multiplication, division, and remainder | Left-to-right |
| 4 | + - | Addition and subtraction | |
| 5 | << >> | Bitwise left shift and right shift | |
| 6 | < <= | For relational operators < and ≤ respectively | |
> >= | For relational operators > and ≥ respectively | ||
| 7 | == != | For relational = and ≠ respectively | |
| 8 | & | Bitwise AND | |
| 9 | ^ | Bitwise XOR (exclusive or) | |
| 10 | | | Bitwise OR (inclusive or) | |
| 11 | && | Logical AND | |
| 12 | || | Logical OR | |
| 13[note 1] | ?: | Ternary conditional[note 2] | Right-to-Left |
| 14 | = | Simple assignment | |
+= -= | Assignment by sum and difference | ||
*= /= %= | Assignment by product, quotient, and remainder | ||
<<= >>= | Assignment by bitwise left shift and right shift | ||
&= ^= |= | Assignment by bitwise AND, XOR, and OR | ||
| 15 | , | Comma | Left-to-right |
Thursday, January 21, 2016
Two's Compliment
Today I'm reading about two's complement and the difference between signed and unsigned integers. In the near future I'm expecting to know a bunch of random stupid (and probably useful) info about ascii, utf, and hex representations of different characters... Starting by reading here.
Subscribe to:
Posts (Atom)