Commit 94c6f67c authored by Florian Ernst's avatar Florian Ernst

Imported Upstream version 7.1.7

parent 72382fa1
!!!! !!!!
! Abacus: Class resource for xabacus ! Abacus: Class resource for xabacus
!!!! !!!!
! Chinese Saun-pan (Suan Pan)
Abacus*topFactor: 5
Abacus*bottomFactor: 1
Abacus*topOrient: true
Abacus*bottomOrient: false
Abacus*topNumber: 2
Abacus*bottomNumber: 5
Abacus*topSpaces: 2
Abacus*bottomSpaces: 2
Abacus*rails: 13
Abacus*slot: false
Abacus*diamond: false
!Abacus*format: Chinese
!Abacus*format: Japanese
!Abacus*format: Korean
!Abacus*format: Roman
!Abacus*format: Russian
Abacus*format: Other
Abacus*base: 10
Abacus*displayBase: 10
Abacus*vertical: false
Abacus*romanNumerals: false
Abacus*quarter: false
!!Abacus*quarterPercent: false
Abacus*mono: false Abacus*mono: false
Abacus*reverse: false Abacus*reverse: false
Abacus*beadColor: DarkRed
Abacus*beadBorder: gray25
Abacus*frameColor: cyan
Abacus*railColor: gold
Abacus*foreground: black Abacus*foreground: black
Abacus*background: #AEB2C3 Abacus*background: #AEB2C3
Abacus*frameColor: cyan
Abacus*railColor: gold
Abacus*beadColor: DarkRed
Abacus*beadBorder: gray25
Abacus*delay: 50 Abacus*delay: 50
Abacus*sound: false Abacus*sound: false
Abacus*bumpSound: @READPATH@/bump.au Abacus*bumpSound: @READPATH@/bump.au
...@@ -59,25 +35,46 @@ Abacus*demoPath: @READPATH@ ...@@ -59,25 +35,46 @@ Abacus*demoPath: @READPATH@
!Abacus*demoPath: /usr/local/share/games/xabacus !Abacus*demoPath: /usr/local/share/games/xabacus
!Abacus*demoPath: /usr/share/games/xabacus !Abacus*demoPath: /usr/share/games/xabacus
! !
! Chinese Saun-pan (Suan Pan)
Abacus*vertical: false
Abacus*slot: false
Abacus*diamond: false
Abacus*topOrient: true
Abacus*bottomOrient: false
Abacus*topFactor: 5
Abacus*bottomFactor: 1
Abacus*topNumber: 2
Abacus*bottomNumber: 5
Abacus*topSpaces: 2
Abacus*bottomSpaces: 2
Abacus*topPiece: 0
Abacus*bottomPiece: 0
Abacus*topPiecePercent: 0
Abacus*bottomPiecePercent: 0
Abacus*shiftPercent: 2
Abacus*sign: false
Abacus*decimalPosition: 2
Abacus*groupSize: 3
Abacus*rails: 13
Abacus*base: 10
Abacus*anomaly: 0
Abacus*shiftAnomaly: 2
Abacus*anomalySq: 0
Abacus*shiftAnomalySq: 2
Abacus*displayBase: 10
Abacus*romanNumerals: false
! format of Other allows you to fine tune options (or else may be clobbered)
!Abacus*format: Chinese
!Abacus*format: Japanese
!Abacus*format: Korean
!Abacus*format: Roman
!Abacus*format: Russian
Abacus*format: Other
!
! override the above with these to have different abacii ! override the above with these to have different abacii
! Chinese base 16 Saun-pan ! Chinese Saun-pan (Suan Pan)
Abacus16*topFactor: 8
Abacus16*topNumber: 2
Abacus16*bottomNumber: 8
Abacus16*rails: 15
Abacus16*base: 16
Abacus20*displayBase: 16
! Japanese base 20 Soroban or Mesoamerican (Aztec) Nepohualtzitzin
Abacus20*topNumber: 3
Abacus20*bottomNumber: 4
Abacus20*base: 20
Abacus20*displayBase: 20
! The Aztecs had base 20 with the exception of the 3rd decimal place where
! instead of 20*20=400 the third place marked 360 and the 4th place was
! 20*360, etc.. They independently created their own zero (only Babylon
! (base 60) and India (base 10) have done this) but the anomaly took away
! its true power. This abacus here is without the anomaly.
Abacuscn*format: Chinese Abacuscn*format: Chinese
! Japanese post-WWII Soroban
Abacusjp*topNumber: 1 Abacusjp*topNumber: 1
Abacusjp*bottomNumber: 4 Abacusjp*bottomNumber: 4
Abacusjp*topSpaces: 1 Abacusjp*topSpaces: 1
...@@ -97,18 +94,46 @@ Abacusro*topNumber: 1 ...@@ -97,18 +94,46 @@ Abacusro*topNumber: 1
Abacusro*bottomNumber: 4 Abacusro*bottomNumber: 4
Abacusro*topSpaces: 1 Abacusro*topSpaces: 1
Abacusro*bottomSpaces: 1 Abacusro*bottomSpaces: 1
Abacusro*rails: 15 Abacusro*topPiece: 2
Abacusro*bottomPiece: 6
Abacusro*rails: 9
Abacusro*slot: true Abacusro*slot: true
Abacusro*format: Roman Abacusro*format: Roman
Abacusro*romanNumerals: true Abacusro*romanNumerals: true
! Way of easily figuring out seconds, given hours, minutes, seconds
!Abacusro*anomaly: 4
!Abacusro*shiftAnomaly: 2
!Abacusro*anomalySq: 4
!Abacusro*shiftAnomalySq: 2
! Russian Schoty ! Russian Schoty
Abacusru*bottomFactor: 1 Abacusru*bottomFactor: 1
Abacusru*bottomOrient: true Abacusru*bottomOrient: true
Abacusru*topNumber: 0 Abacusru*topNumber: 0
Abacusru*bottomNumber: 10 Abacusru*bottomNumber: 10
Abacusru*topSpaces: 0 Abacusru*topSpaces: 0
Abacusru*bottomPiece: 4
Abacusru*bottomPiecePercent: 4
Abacusru*shiftPercent: 2
Abacusru*rails: 11 Abacusru*rails: 11
Abacusru*format: Russian Abacusru*format: Russian
Abacusru*vertical: true Abacusru*vertical: true
Abacusru*quarter: true ! Chinese base 16 Saun-pan
!Abacusru*quarterPercent: true Abacus16*topFactor: 8
Abacus16*topNumber: 2
Abacus16*bottomNumber: 8
Abacus16*rails: 15
Abacus16*base: 16
Abacus16*displayBase: 16
! Japanese base 20 Soroban or Mesoamerican Nepohualtzintzin
Abacusma*topNumber: 3
Abacusma*bottomNumber: 4
Abacusma*base: 20
Abacusma*displayBase: 20
Abacusma*anomaly: 2
Abacusma*shiftAnomaly: 2
! Chinese solid-and-broken-bar system
Abacuscn12*topFactor: 3
Abacuscn12*topNumber: 3
Abacuscn12*bottomNumber: 2
Abacuscn12*base: 12
Abacuscn12*displayBase: 12
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -38,36 +38,17 @@ ...@@ -38,36 +38,17 @@
***********************************************************************/ ***********************************************************************/
#if 0 #if 0
/* This is not ready for prime-time. */ #define DEBUG 1
#define QUARTER_PERCENT 1
#endif #endif
#ifndef WINVER #ifndef WINVER
#define XtNselectCallback ((char *) "selectCallback") #define XtNselectCallback ((char *) "selectCallback")
#define XtNrails ((char *) "rails") #define XtNmono ((char *) "mono")
#define XtNbase ((char *) "base") #define XtNreverse ((char *) "reverse")
#define XtNdisplayBase ((char *) "displayBase")
#define XtNvertical ((char *) "vertical")
#define XtNsign ((char *) "sign")
#define XtNquarter ((char *) "quarter")
#define XtNquarterPercent ((char *) "quarterPercent")
#define XtNmode ((char *) "mode")
#define XtNformat ((char *) "format")
#define XtNromanNumerals ((char *) "romanNumerals")
#define XtNtopNumber ((char *) "topNumber")
#define XtNtopOrient ((char *) "topOrient")
#define XtNtopFactor ((char *) "topFactor")
#define XtNtopSpaces ((char *) "topSpaces")
#define XtNbottomNumber ((char *) "bottomNumber")
#define XtNbottomOrient ((char *) "bottomOrient")
#define XtNbottomFactor ((char *) "bottomFactor")
#define XtNbottomSpaces ((char *) "bottomSpaces")
#define XtNframeColor ((char *) "frameColor") #define XtNframeColor ((char *) "frameColor")
#define XtNrailColor ((char *) "railColor") #define XtNrailColor ((char *) "railColor")
#define XtNbeadColor ((char *) "beadColor") #define XtNbeadColor ((char *) "beadColor")
#define XtNbeadBorder ((char *) "beadBorder") #define XtNbeadBorder ((char *) "beadBorder")
#define XtNmono ((char *) "mono")
#define XtNreverse ((char *) "reverse")
#define XtNdelay ((char *) "delay") #define XtNdelay ((char *) "delay")
#define XtNsound ((char *) "sound") #define XtNsound ((char *) "sound")
#define XtNbumpSound ((char *) "bumpSound") #define XtNbumpSound ((char *) "bumpSound")
...@@ -75,46 +56,53 @@ ...@@ -75,46 +56,53 @@
#define XtNbuffer ((char *) "buffer") #define XtNbuffer ((char *) "buffer")
#define XtNscript ((char *) "script") #define XtNscript ((char *) "script")
#define XtNdemo ((char *) "demo") #define XtNdemo ((char *) "demo")
#define XtNdecimalPosition ((char *) "decimalPosition")
#define XtNmenu ((char *) "menu")
#define XtNdemoPath ((char *) "demoPath") #define XtNdemoPath ((char *) "demoPath")
#define XtNdemoFont ((char *) "demoFont") #define XtNdemoFont ((char *) "demoFont")
#define XtNdemoForeground ((char *) "demoForeground") #define XtNdemoForeground ((char *) "demoForeground")
#define XtNdemoBackground ((char *) "demoBackground") #define XtNdemoBackground ((char *) "demoBackground")
#define XtNvertical ((char *) "vertical")
#define XtNslot ((char *) "slot")
#define XtNdiamond ((char *) "diamond")
#define XtNtopOrient ((char *) "topOrient")
#define XtNbottomOrient ((char *) "bottomOrient")
#define XtNtopNumber ((char *) "topNumber")
#define XtNbottomNumber ((char *) "bottomNumber")
#define XtNtopFactor ((char *) "topFactor")
#define XtNbottomFactor ((char *) "bottomFactor")
#define XtNtopSpaces ((char *) "topSpaces")
#define XtNbottomSpaces ((char *) "bottomSpaces")
#define XtNtopPiece ((char *) "topPiece")
#define XtNbottomPiece ((char *) "bottomPiece")
#define XtNtopPiecePercent ((char *) "topPiecePercent")
#define XtNbottomPiecePercent ((char *) "bottomPiecePercent")
#define XtNshiftPercent ((char *) "shiftPercent")
#define XtNsign ((char *) "sign")
#define XtNdecimalPosition ((char *) "decimalPosition")
#define XtNgroupSize ((char *) "groupSize")
#define XtNrails ((char *) "rails")
#define XtNbase ((char *) "base")
#define XtNanomaly ((char *) "anomaly")
#define XtNshiftAnomaly ((char *) "shiftAnomaly")
#define XtNanomalySq ((char *) "anomalySq")
#define XtNshiftAnomalySq ((char *) "shiftAnomalySq")
#define XtNdisplayBase ((char *) "displayBase")
#define XtNromanNumerals ((char *) "romanNumerals")
#define XtNmode ((char *) "mode")
#define XtNformat ((char *) "format")
#define XtNmenu ((char *) "menu")
#define XtNdeck ((char *) "deck") #define XtNdeck ((char *) "deck")
#define XtNrail ((char *) "rail") #define XtNrail ((char *) "rail")
#define XtNnumber ((char *) "number") #define XtNnumber ((char *) "number")
#define XtNframed ((char *) "framed") #define XtNframed ((char *) "framed")
#define XtNslot ((char *) "slot")
#define XtNdiamond ((char *) "diamond")
#define XtNaux ((char *) "aux") #define XtNaux ((char *) "aux")
#define XtNmathBuffer ((char *) "mathBuffer") #define XtNmathBuffer ((char *) "mathBuffer")
#define XtNversionOnly ((char *) "versionOnly") #define XtNversionOnly ((char *) "versionOnly")
#define XtCRails ((char *) "Rails") #define XtCMono ((char *) "Mono")
#define XtCSpaces ((char *) "Spaces") #define XtCReverse ((char *) "Reverse")
#define XtCBase ((char *) "Base")
#define XtCDisplayBase ((char *) "DisplayBase")
#define XtCVertical ((char *) "Vertical")
#define XtCSign ((char *) "Sign")
#define XtCQuarter ((char *) "Quarter")
#define XtCQuarterPercent ((char *) "QuarterPercent")
#define XtCMode ((char *) "Mode")
#define XtCFormat ((char *) "Format")
#define XtCRomanNumerals ((char *) "RomanNumerals")
#define XtCTopNumber ((char *) "TopNumber")
#define XtCTopFactor ((char *) "TopFactor")
#define XtCTopOrient ((char *) "TopOrient")
#define XtCTopSpaces ((char *) "TopSpaces")
#define XtCBottomNumber ((char *) "BottomNumber")
#define XtCBottomFactor ((char *) "BottomFactor")
#define XtCBottomOrient ((char *) "BottomOrient")
#define XtCBottomSpaces ((char *) "BottomSpaces")
#define XtCFrameColor ((char *) "FrameColor") #define XtCFrameColor ((char *) "FrameColor")
#define XtCRailColor ((char *) "RailColor") #define XtCRailColor ((char *) "RailColor")
#define XtCBeadColor ((char *) "BeadColor") #define XtCBeadColor ((char *) "BeadColor")
#define XtCBeadBorder ((char *) "BeadBorder") #define XtCBeadBorder ((char *) "BeadBorder")
#define XtCMono ((char *) "Mono")
#define XtCReverse ((char *) "Reverse")
#define XtCDelay ((char *) "Delay") #define XtCDelay ((char *) "Delay")
#define XtCSound ((char *) "Sound") #define XtCSound ((char *) "Sound")
#define XtCBumpSound ((char *) "BumpSound") #define XtCBumpSound ((char *) "BumpSound")
...@@ -122,18 +110,44 @@ ...@@ -122,18 +110,44 @@
#define XtCBuffer ((char *) "Buffer") #define XtCBuffer ((char *) "Buffer")
#define XtCScript ((char *) "Script") #define XtCScript ((char *) "Script")
#define XtCDemo ((char *) "Demo") #define XtCDemo ((char *) "Demo")
#define XtCDecimalPosition ((char *) "DecimalPosition")
#define XtCMenu ((char *) "Menu")
#define XtCDemoPath ((char *) "DemoPath") #define XtCDemoPath ((char *) "DemoPath")
#define XtCDemoFont ((char *) "DemoFont") #define XtCDemoFont ((char *) "DemoFont")
#define XtCDemoForeground ((char *) "DemoForeground") #define XtCDemoForeground ((char *) "DemoForeground")
#define XtCDemoBackground ((char *) "DemoBackground") #define XtCDemoBackground ((char *) "DemoBackground")
#define XtCVertical ((char *) "Vertical")
#define XtCSlot ((char *) "Slot")
#define XtCDiamond ((char *) "Diamond")
#define XtCTopOrient ((char *) "TopOrient")
#define XtCBottomOrient ((char *) "BottomOrient")
#define XtCTopNumber ((char *) "TopNumber")
#define XtCBottomNumber ((char *) "BottomNumber")
#define XtCTopFactor ((char *) "TopFactor")
#define XtCBottomFactor ((char *) "BottomFactor")
#define XtCTopSpaces ((char *) "TopSpaces")
#define XtCBottomSpaces ((char *) "BottomSpaces")
#define XtCTopPiece ((char *) "TopPiece")
#define XtCBottomPiece ((char *) "BottomPiece")
#define XtCTopPiecePercent ((char *) "TopPiecePercent")
#define XtCBottomPiecePercent ((char *) "BottomPiecePercent")
#define XtCShiftPercent ((char *) "ShiftPercent")
#define XtCSign ((char *) "Sign")
#define XtCDecimalPosition ((char *) "DecimalPosition")
#define XtCGroupSize ((char *) "GroupSize")
#define XtCRails ((char *) "Rails")
#define XtCBase ((char *) "Base")
#define XtCAnomaly ((char *) "Anomaly")
#define XtCShiftAnomaly ((char *) "ShiftAnomaly")
#define XtCAnomalySq ((char *) "AnomalySq")
#define XtCShiftAnomalySq ((char *) "ShiftAnomalySq")
#define XtCDisplayBase ((char *) "DisplayBase")
#define XtCRomanNumerals ((char *) "RomanNumerals")
#define XtCMode ((char *) "Mode")
#define XtCFormat ((char *) "Format")
#define XtCMenu ((char *) "Menu")
#define XtCDeck ((char *) "Deck") #define XtCDeck ((char *) "Deck")
#define XtCRail ((char *) "Rail") #define XtCRail ((char *) "Rail")
#define XtCNumber ((char *) "Number") #define XtCNumber ((char *) "Number")
#define XtCFramed ((char *) "Framed") #define XtCFramed ((char *) "Framed")
#define XtCSlot ((char *) "Slot")
#define XtCDiamond ((char *) "Diamond")
#define XtCAux ((char *) "Aux") #define XtCAux ((char *) "Aux")
#define XtCMathBuffer ((char *) "MathBuffer") #define XtCMathBuffer ((char *) "MathBuffer")
typedef struct _AbacusClassRec *AbacusWidgetClass; typedef struct _AbacusClassRec *AbacusWidgetClass;
...@@ -170,7 +184,10 @@ typedef struct { ...@@ -170,7 +184,10 @@ typedef struct {
#define ABACUS_SIGN 5 #define ABACUS_SIGN 5
#define ABACUS_QUARTER 6 #define ABACUS_QUARTER 6
#define ABACUS_QUARTERPERCENT 7 #define ABACUS_QUARTERPERCENT 7
#define ABACUS_FORMAT 8 #define ABACUS_TWELFTH 8
#define ABACUS_ANOMALY 9
#define ABACUS_WATCH 10
#define ABACUS_FORMAT 11
#define PRIMARY 0 #define PRIMARY 0
#define LEFTAUX 1 #define LEFTAUX 1
...@@ -205,9 +222,7 @@ typedef struct { ...@@ -205,9 +222,7 @@ typedef struct {
#define DEFAULTBASE 10 #define DEFAULTBASE 10
#define QUARTERS 4 #define QUARTERS 4
#define QUARTERPERCENTS 4 #define QUARTERPERCENTS 4
#define TWELFTH 12
/* Migrate to Locale */
#define MAX_FRACTION_DIGITS 2
typedef struct _AbacusRec *AbacusWidget; typedef struct _AbacusRec *AbacusWidget;
typedef struct _AbacusRec *AbacusDemoWidget; typedef struct _AbacusRec *AbacusDemoWidget;
......
...@@ -793,7 +793,7 @@ static void evaluateExpression(double *myLeft, char *binaryOperation) ...@@ -793,7 +793,7 @@ static void evaluateExpression(double *myLeft, char *binaryOperation)
while (!emptyExpression()) { while (!emptyExpression()) {
myRight = *myLeft; myRight = *myLeft;
getPreviousExpressionPart(myLeft, binaryOperation); getPreviousExpressionPart(myLeft, binaryOperation);
if (binaryOperation != '\0') if (binaryOperation != NULL)
*myLeft = evaluateDouble(*myLeft, *binaryOperation, *myLeft = evaluateDouble(*myLeft, *binaryOperation,
myRight); myRight);
else else
...@@ -835,6 +835,7 @@ parse(double input, Boolean numeral, char newOperation) ...@@ -835,6 +835,7 @@ parse(double input, Boolean numeral, char newOperation)
if (negateNext) { if (negateNext) {
negateNext = False; negateNext = False;
right = -input; right = -input;
pendingOperation = '\0';
} else { } else {
right = input; right = input;
} }
......
...@@ -228,7 +228,7 @@ SetAllColors(AbacusWidget w, Boolean init) ...@@ -228,7 +228,7 @@ SetAllColors(AbacusWidget w, Boolean init)
XtReleaseGC((Widget) w, w->abacusDemo.inverseGC); XtReleaseGC((Widget) w, w->abacusDemo.inverseGC);
w->abacusDemo.inverseGC = XtGetGC((Widget) w, valueMask, &values); w->abacusDemo.inverseGC = XtGetGC((Widget) w, valueMask, &values);
if (w->abacusDemo.fontInfo) if (w->abacusDemo.fontInfo)
XSetFont(XtDisplay(w), w->abacusDemo.foregroundGC, (void) XSetFont(XtDisplay(w), w->abacusDemo.foregroundGC,
w->abacusDemo.fontInfo->fid); w->abacusDemo.fontInfo->fid);
} }
...@@ -670,7 +670,7 @@ DestroyAbacusDemo(Widget old) ...@@ -670,7 +670,7 @@ DestroyAbacusDemo(Widget old)
XtReleaseGC(old, w->abacusDemo.foregroundGC); XtReleaseGC(old, w->abacusDemo.foregroundGC);
XtReleaseGC(old, w->abacusDemo.inverseGC); XtReleaseGC(old, w->abacusDemo.inverseGC);
XtRemoveCallbacks(old, XtNselectCallback, w->abacus.select); XtRemoveCallbacks(old, XtNselectCallback, w->abacus.select);
XFreeFont(XtDisplay(w), w->abacusDemo.fontInfo); (void) XFreeFont(XtDisplay(w), w->abacusDemo.fontInfo);
} }
#else #else
......
...@@ -51,7 +51,13 @@ is no recorded usage of a larger Roman numeral in Roman times. ...@@ -51,7 +51,13 @@ is no recorded usage of a larger Roman numeral in Roman times.
An older notation for Roman numerals was represented thus: An older notation for Roman numerals was represented thus:
( = C, I) = D, (I) = M, I)) = v, ((I)) = x, I))) = l, (((I))) = c, ( = C, I) = D, (I) = M, I)) = v, ((I)) = x, I))) = l, (((I))) = c,
_ _
|X| = m */ |X| = m
Fractions
12 ounces (uncia) in a as
S = 1/2 ounce
) = 1/4 ounce
Z = 1/3 ounce
*/
}; };
#ifdef HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
...@@ -133,7 +139,8 @@ int2String(char *buf, LONG number, int base, Boolean negative) ...@@ -133,7 +139,8 @@ int2String(char *buf, LONG number, int base, Boolean negative)
} }
static int static int
flt2String(char *buf, LONG number, int abacusBase, int base, int places, int decimalPosition) flt2String(char *buf, LONG number, int abacusBase, int base, int places,
int decimalPosition)
{ {
int position = 0, digit; int position = 0, digit;
double mult = 1.0 / base; double mult = 1.0 / base;
...@@ -209,13 +216,12 @@ squareroot(int i) ...@@ -209,13 +216,12 @@ squareroot(int i)
} }
void void
dividePieces(char * buf, int base, int pieces, int mult, int places) dividePieces(char *buf, int base, int pieces, int mult, int places)
{ {
int position, digit, inter; int position, digit, inter;
digit = mult / pieces; digit = mult / pieces;
inter = mult % pieces; inter = mult % pieces;
/* This works because digit should never be greater than base here */
(void) sprintf(buf, "%1d.", digit); (void) sprintf(buf, "%1d.", digit);
for (position = 2; position < places;) { for (position = 2; position < places;) {
digit = (inter * base) / pieces; digit = (inter * base) / pieces;
...@@ -228,6 +234,40 @@ dividePieces(char * buf, int base, int pieces, int mult, int places) ...@@ -228,6 +234,40 @@ dividePieces(char * buf, int base, int pieces, int mult, int places)
buf[position] = '\0'; buf[position] = '\0';
} }
void
shiftDecimal(char *buf, char *aBuf, int shift, int place)
{
int size = strlen(aBuf);
int loc = 0, i = 0;
while (aBuf[loc] != '.' && loc < size) {
buf[i] = aBuf[loc];
loc++;
i++;
}
buf[i] = aBuf[loc];
i++;
while (loc < place + 1) {
loc++;
buf[i] = aBuf[loc];
i++;
}
if (shift > 0) {
/* shift right */
for (i = place + 2; i < shift + place + 2; i++)
buf[i] = '0';
} else {
/* shift left */
loc -= shift;
}
while (loc < size - 1) {
loc++;
buf[i] = aBuf[loc];
i++;
}
buf[i] = '\0';
}
/* 2nd grade math is hard */ /* 2nd grade math is hard */
/* May disregard sign if different */ /* May disregard sign if different */
void void
...@@ -307,10 +347,18 @@ addStrings(char *finalBuf, char *aBuf, char *bBuf, int base) ...@@ -307,10 +347,18 @@ addStrings(char *finalBuf, char *aBuf, char *bBuf, int base)
} else } else
(void) strcpy(finalBuf, bBuf); (void) strcpy(finalBuf, bBuf);
} }
i = strlen(finalBuf) - 1;
while (finalBuf[i] == '0' && finalBuf[i - 1] != '.')
i--;
finalBuf[i + 1] = '\0';
} }
void void
convertString(char * buf, char * inbuf, int base, int displayBase, int decimalPosition) convertString(char * buf, char * inbuf, int base, int displayBase,
int decimalPosition,
int anomaly, int shiftAnomaly,
int anomalySq, int shiftAnomalySq)
{ {
char fltbuf[256]; char fltbuf[256];
int i, last, place = -1, decimalPlace, decimalPointPlace; int i, last, place = -1, decimalPlace, decimalPointPlace;
...@@ -340,8 +388,17 @@ convertString(char * buf, char * inbuf, int base, int displayBase, int decimalPo ...@@ -340,8 +388,17 @@ convertString(char * buf, char * inbuf, int base, int displayBase, int decimalPo
char2Int(inbuf[i])); char2Int(inbuf[i]));
place--; place--;
} else { } else {
intPart += (((LONG) power(base, place)) * if (place >= shiftAnomaly && anomaly != 0) {
char2Int(inbuf[i])); if (place >= shiftAnomalySq + shiftAnomaly && anomalySq != 0)
intPart += (((LONG) power(base, place - 2))) *
char2Int(inbuf[i]) * (base - anomaly) *
(base - anomalySq);
else
intPart += (((LONG) power(base, place - 1))) *
char2Int(inbuf[i]) * (base - anomaly);
} else
intPart += (((LONG) power(base, place)) *
char2Int(inbuf[i]));
place--; place--;
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# #
### ###
# #
# Copyright (c) 1994 - 2005 David Albert Bagley, bagleyd@tux.org # Copyright (c) 1994 - 2006 David Albert Bagley, bagleyd@tux.org
# #
# Abacus demo and neat pointers from # Abacus demo and neat pointers from
# Copyright (c) 1991 - 1998 Luis Fernandes, elf@ee.ryerson.ca # Copyright (c) 1991 - 1998 Luis Fernandes, elf@ee.ryerson.ca
...@@ -62,7 +62,9 @@ extern void RomanNumeralsAbacus(AbacusWidget w); ...@@ -62,7 +62,9 @@ extern void RomanNumeralsAbacus(AbacusWidget w);
extern void SignAbacus(AbacusWidget w); extern void SignAbacus(AbacusWidget w);
extern void QuarterAbacus(AbacusWidget w); extern void QuarterAbacus(AbacusWidget w);
extern void QuarterPercentAbacus(AbacusWidget w); extern void QuarterPercentAbacus(AbacusWidget w);
extern void VerticalAbacus(AbacusWidget w); extern void TwelfthAbacus(AbacusWidget w);
extern void AnomalyAbacus(AbacusWidget w);
extern void WatchAbacus(AbacusWidget w);
extern void EnterAbacus(AbacusWidget w); extern void EnterAbacus(AbacusWidget w);
extern void LeaveAbacus(AbacusWidget w); extern void LeaveAbacus(AbacusWidget w);
...@@ -119,12 +121,11 @@ extern AbacusClassRec abacusClassRec; ...@@ -119,12 +121,11 @@ extern AbacusClassRec abacusClassRec;
#define BOTTOM 0 #define BOTTOM 0
#define CARRY 2 /* I guess it could be even more if you have a weird config #define CARRY 2 /* I guess it could be even more if you have a weird config
also need a space to hold null (not included) */ also need a space to hold null (not included) */
#define SPECIAL_QUARTERS 2 /* Quarters, QuarterPercents */ #define SPECIAL_PIECES 2 /* Pieces, PiecePercents */
/* Migrate to Locale */ /* Migrate to Locale */
#define DECIMAL_SEPARATOR '.' #define DECIMAL_SEPARATOR '.'
#define GROUP_SEPARATOR ',' #define GROUP_SEPARATOR ','
#define GROUPING_SIZE 3
#define MAXLENFORMAT 9 #define MAXLENFORMAT 9
...@@ -147,6 +148,7 @@ typedef struct _DeckPart { ...@@ -147,6 +148,7 @@ typedef struct _DeckPart {
int spaces; /* spaces between beads */ int spaces; /* spaces between beads */
int room; /* spaces + number */ int room; /* spaces + number */
Position height; Position height;
int piece, piecePercent;
} DeckPart; } DeckPart;
typedef struct _AbacusPart { typedef struct _AbacusPart {
...@@ -155,14 +157,16 @@ typedef struct _AbacusPart { ...@@ -155,14 +157,16 @@ typedef struct _AbacusPart {
int rails; /* number of columns of beads */ int rails; /* number of columns of beads */
int decimalPosition, numDigits; int decimalPosition, numDigits;
int base, displayBase; /* 10 usually */ int base, displayBase; /* 10 usually */
int shiftPercent, shiftAnomaly, shiftAnomalySq;
int groupSize, anomaly, anomalySq;
int delay, numSlices, mode; int delay, numSlices, mode;
int deck, rail, number; int deck, rail, number;
Position width, midHeight, midBarY, railWidth; Position width, midHeight, midBarY, railWidth;
Point frameSize, beadSize; Point frameSize, beadSize;
Point pos, delta, offset; Point pos, delta, offset;
Boolean sign, romanNumerals;
Boolean mono, reverse, script, demo, focus, vertical, aux; Boolean mono, reverse, script, demo, focus, vertical, aux;
Boolean versionOnly; Boolean versionOnly;
Boolean sign, quarter, quarterPercent, romanNumerals;
Boolean slot, diamond, sound; Boolean slot, diamond, sound;
char *digits, *mathBuffer; char *digits, *mathBuffer;
FILE *fp; FILE *fp;
...@@ -216,12 +220,15 @@ extern char int2Char(int digit); ...@@ -216,12 +220,15 @@ extern char int2Char(int digit);
extern void dividePieces(char * buf, int base, int pieces, extern void dividePieces(char * buf, int base, int pieces,
int mult, int places); int mult, int places);
extern void shiftDecimal(char *buf, char *aBuf, int shift, int place);
extern void addStrings(char *finalBuf, char *buf, char *pieceBuf, extern void addStrings(char *finalBuf, char *buf, char *pieceBuf,
int base); int base);
extern void subStrings(char *finalBuf, char *buf, char *pieceBuf, extern void subStrings(char *finalBuf, char *buf, char *pieceBuf,
int base); int base);
extern void convertString(char * buf, char * inbuf, extern void convertString(char * buf, char * inbuf,
int base, int displayBase, int decimalPosition); int base, int displayBase, int decimalPosition,
int anomaly, int shiftAnomaly,
int anomalySq, int shiftAnomalySq);
extern int sizeofRoman(int base, Boolean romanNumerals); extern int sizeofRoman(int base, Boolean romanNumerals);
extern int string2Roman(char *buf, char *inbuf, int base); extern int string2Roman(char *buf, char *inbuf, int base);
......
############################################################ ############################################################
# #
# $Id : Makefile.in 7.1.5 2005/10/05 $ # $Id : Makefile.in 7.1.7 2006/01/01 $
# #
# xabacus Makefile.in for configure (UNIX X11 support) # xabacus Makefile.in for configure (UNIX X11 support)
############################################################ ############################################################
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
wIDGET = abacus wIDGET = abacus
WIDGET = Abacus WIDGET = Abacus
VERNUM = 7.1.5 VERNUM = 7.1.7
GROUP = xabacus GROUP = xabacus
P=x P=x
R=$(P) R=$(P)
...@@ -400,23 +400,13 @@ $(RM) $(VER).tar ...@@ -400,23 +400,13 @@ $(RM) $(VER).tar
dist.man : $(PROG).html vms/$(PROG).hlp dist.man : $(PROG).html vms/$(PROG).hlp
# found man2hlp.sh in lynx source
vms/$(PROG).hlp : $(PROG).man