bash-4.3$ date Mon Feb 27 13:05:13 EST 2017 bash-4.3$ pwd /home/accts/sbs5/cs223/www/current/lectures bash-4.3$ cd bash-4.3$ cd cs223/hw4 bash-4.3$ ls Calc.o stack.h stacktest.c test test2a test5 Calcx stack.o stacktest.c~ test1 test3 test6 Makefile stacktest stacktest.o test2 test4 Tests bash-4.3$ ./Calcx 1 + 3 # 2 Input: 1 + 3 # 2 Fatal Error. Bad token: # bash-4.3$ !! ./Calcx 1 + 3 * 2 Input: 1 + 3 * 2 Result: 7.00 1 * 3 + 2 Input: 1 * 3 + 2 Result: 5.00 12345678901234567 + 1 Input: 12345678901234567 + 1 Result: 12345678901234568.00 1234567890123456789 + 1 Input: 1234567890123456789 + 1 Result: 1234567890123456768.00 bash-4.3$ cd bash-4.3$ cd cs223/www/current/lectures/code bash-4.3$ ./lp0227 The biggest double: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 Examples of ftoa code: 0: 0.000000 .00 1: 0.500000 .50 2: 1.000000 1.00 3: 1.500000 1.50 4: 2.000000 2.00 5: 2.500000 2.50 6: 3.000000 3.00 7: 3.500000 3.50 8: 4.000000 4.00 9: 4.500000 4.50 bash-4.3$ ./lp0227 1234567890123456 The biggest double: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 argv[1] 1234567890123456 1234567890123456.000000 Examples of ftoa code: 0: 0.000000 .00 1: 0.500000 .50 2: 1.000000 1.00 3: 1.500000 1.50 4: 2.000000 2.00 5: 2.500000 2.50 6: 3.000000 3.00 7: 3.500000 3.50 8: 4.000000 4.00 9: 4.500000 4.50 bash-4.3$ !!7 ./lp0227 12345678901234567 The biggest double: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 argv[1] 12345678901234567 12345678901234568.000000 Examples of ftoa code: 0: 0.000000 .00 1: 0.500000 .50 2: 1.000000 1.00 3: 1.500000 1.50 4: 2.000000 2.00 5: 2.500000 2.50 6: 3.000000 3.00 7: 3.500000 3.50 8: 4.000000 4.00 9: 4.500000 4.50 bash-4.3$ !!8 ./lp0227 123456789012345678 The biggest double: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 argv[1] 123456789012345678 123456789012345680.000000 Examples of ftoa code: 0: 0.000000 .00 1: 0.500000 .50 2: 1.000000 1.00 3: 1.500000 1.50 4: 2.000000 2.00 5: 2.500000 2.50 6: 3.000000 3.00 7: 3.500000 3.50 8: 4.000000 4.00 9: 4.500000 4.50 bash-4.3$ cd bash-4.3$ cd cs223 bash-4.3$ cd hw4 bash-4.3$ ./Calcx 1 + 2 + 3 Input: 1 + 2 + 3 Result: 6.00 bash-4.3$ ./Calcx -debug 1 + 2 + 3 Input: 1 + 2 + 3 Stack: size: 0 : Token:1: type: 0 value: 1.00 Stack: size: 0 : Token:+: type: 1 value: 0.00 Stack: size: 1 :[1 + 0.0] Token:2: type: 0 value: 2.00 Stack: size: 1 :[1 + 0.0] Token:+: type: 1 value: 0.00 Stack: size: 1 :[1 + 0.0] Token:3: type: 0 value: 3.00 Stack: size: 1 :[1 + 0.0] OUTPUT: Stack: size: 0 : Token:1: type: 0 value: 1.00 Stack: size: 1 :[0 1 1.0] Token:2: type: 0 value: 2.00 Stack: size: 2 :[0 2 2.0] [0 1 1.0] Token:+: type: 1 value: 0.00 Stack: size: 1 :[0 2 3.0] Token:3: type: 0 value: 3.00 Stack: size: 2 :[0 3 3.0] [0 2 3.0] Token:+: type: 1 value: 0.00 Result: 6.00 3 4 + Input: 3 4 + Stack: size: 0 : Token:3: type: 0 value: 3.00 Stack: size: 0 : Token:4: type: 0 value: 4.00 Stack: size: 0 : Token:+: type: 1 value: 0.00 Stack: size: 1 :[1 + 0.0] OUTPUT: Stack: size: 0 : Token:3: type: 0 value: 3.00 Stack: size: 1 :[0 3 3.0] Token:4: type: 0 value: 4.00 Stack: size: 2 :[0 4 4.0] [0 3 3.0] Token:+: type: 1 value: 0.00 Result: 7.00 3 4 5 + * Input: 3 4 5 + * Stack: size: 0 : Token:3: type: 0 value: 3.00 Stack: size: 0 : Token:4: type: 0 value: 4.00 Stack: size: 0 : Token:5: type: 0 value: 5.00 Stack: size: 0 : Token:+: type: 1 value: 0.00 Stack: size: 1 :[1 + 0.0] Token:*: type: 2 value: 0.00 Stack: size: 2 :[2 * 0.0] [1 + 0.0] OUTPUT: Stack: size: 0 : Token:3: type: 0 value: 3.00 Stack: size: 1 :[0 3 3.0] Token:4: type: 0 value: 4.00 Stack: size: 2 :[0 4 4.0] [0 3 3.0] Token:5: type: 0 value: 5.00 Stack: size: 3 :[0 5 5.0] [0 4 4.0] [0 3 3.0] Token:*: type: 2 value: 0.00 Stack: size: 2 :[0 5 20.0] [0 3 3.0] Token:+: type: 1 value: 0.00 Result: 23.00 bash-4.3$ ls Calc.o stack.h stacktest.c test test2a test5 Calcx stack.o stacktest.c~ test1 test3 test6 Makefile stacktest stacktest.o test2 test4 Tests bash-4.3$ ./stacktest Usage: stacktest numbers+ bash-4.3$ !! 1 2 3 4 ./stacktest 1 2 3 4 Stack: size: 4 :[0 4 4.0] [0 3 3.0] [0 2 2.0] [0 1 1.0] Stack: size: 3 :[0 3 3.0] [0 2 2.0] [0 1 1.0] bash-4.3$ !! 5 6 7 8 9 0 1 2 3 ./stacktest 1 2 3 4 5 6 7 8 9 0 1 2 3 Can't push element on stack: stack is full. bash-4.3$ valgrind ./Calcx 1 2 3 4 5 ==17190== Memcheck, a memory error detector ==17190== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==17190== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==17190== Command: ./Calcx 1 2 3 4 5 ==17190== Usage: Calc [-debug] ==17190== ==17190== HEAP SUMMARY: ==17190== in use at exit: 0 bytes in 0 blocks ==17190== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==17190== ==17190== All heap blocks were freed -- no leaks are possible ==17190== ==17190== For counts of detected and suppressed errors, rerun with: -v ==17190== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) bash-4.3$ valgrind ./stacktest 1 2 3 4 ==17206== Memcheck, a memory error detector ==17206== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==17206== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==17206== Command: ./stacktest 1 2 3 4 ==17206== Stack: size: 4 :[0 4 4.0] [0 3 3.0] [0 2 2.0] [0 1 1.0] Stack: size: 3 :[0 3 3.0] [0 2 2.0] [0 1 1.0] ==17206== ==17206== HEAP SUMMARY: ==17206== in use at exit: 0 bytes in 0 blocks ==17206== total heap usage: 10 allocs, 10 frees, 1,208 bytes allocated ==17206== ==17206== All heap blocks were freed -- no leaks are possible ==17206== ==17206== For counts of detected and suppressed errors, rerun with: -v ==17206== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) bash-4.3$ exit Process shell finished