Mathjax

jsxgraph

Wednesday, July 31, 2013

Factorial Summary

Time to summarize the factorial study and move on to other fun topics.

Computer representation of numbers

The key issue with large numbers like factorials, is how they are represented on the computer.  For performing mathematical operations the computer hardware has fixed size numbers.  For integer number types, this is related to the size of registers and number of wires connecting devices.  Each bit of a number is held in a flip-flop.  A flip-flop is an electronic device with two stable states, one representing a 0 and the other a 1.

Monday, July 22, 2013

X11 factorial code with Xft and GMP

/*
This is the factorial code using X11 with Xft and GMP.  Xft provides anti-aliased fonts and can be toggled on or off with an 'a' or 'x' keys.  The results from the Gnu Multi-Precision Library can have the precision reduced by bit masking the results to 8, 4, 2 or 1 Byte by pressing the 'p' key.  The results can also be presented in binary or hexadecimal by pressing the 'b' key.  The number digits are entered with number keys.  The 'delete' or 'backspace' keys remove the last digit.  The 'enter' or 'return' keys clear the number.

The code listing is color highlighted -
  gray - is comments, ignored by the compiler
  green - pre-processor directives
  blue - native primitive variable types
  black - normal code
  bold pink / bold light green - documentation key words
  bold light blue - documentation key word targets
  light brown - integer constants
  red - constant character arrays ( strings )
  purple - character constant
  
  The code should copy into an editor without color highlighting.

Saturday, July 13, 2013

Factorial, getting gui with X11

Factorial with a X Windows user interface


With this post I looked at programming for the X Window System (X11). X11 is hardware-independent application programming interface (API) for graphical user interface (GUI) programming that includes commands for drawing to a screen and user interaction through key board, mouse or other input devices.   The interface provides a means for software to communicate with graphics hardware including over a network.  X11 was designed with local GUI interaction for programs running on a remote computer as a major issue.  The X Window System was started at Massachusetts Institute of Technology (MIT) in 1984 and quickly became the de facto standard for networked workstations.  The X Window System is constantly being improved, but the default X11 is a pixel based system which produces ugly text without anti-aliasing.   A pixel based system draws a color to pixels so that object's edges appear jagged.  Anti-aliasing reduces the jagged edges by drawing varying colors around the border of objects to blend the object color with the surrounding colors. 

To access the code which is amply commented see the post C code for factorial program using X11, Xft and GMP.  A screen shot of the program with anti-aliased fonts.