Thread: I can't spot my mistake...

  1. #181
    Registered User
    Join Date
    Sep 2020
    Posts
    55
    Seems not many people interested here. Why don't you try your luck in another forum:
    UNIX/Linux Programming - C++ Forum
    or
    C and C++ Forum | Dream.In.Code

    BTW. Your code calls many functions, are you sure they all work correctly?

  2. #182
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Quote Originally Posted by thmm View Post
    Seems not many people interested here. Why don't you try your luck in another forum:
    UNIX/Linux Programming - C++ Forum
    or
    C and C++ Forum | Dream.In.Code

    BTW. Your code calls many functions, are you sure they all work correctly?
    Yes I'm sure, thanks for the links btw, I'll try the dream in code one later since that seems more appropriate

  3. #183
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Quote Originally Posted by thmm View Post
    Seems not many people interested here. Why don't you try your luck in another forum:
    UNIX/Linux Programming - C++ Forum
    or
    C and C++ Forum | Dream.In.Code

    BTW. Your code calls many functions, are you sure they all work correctly?
    I registered on the Dream In Code site that same night, tried re-sending the email confirmation several times, double and triple checked my email address, not had any confirmation email yet, I'm now blacklisting that site as one I will NEVER use

  4. #184
    Registered User
    Join Date
    Sep 2020
    Posts
    55
    What browser do you use?
    This site doesn't work properly on Firefox.

  5. #185
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Quote Originally Posted by thmm View Post
    What browser do you use?
    This site doesn't work properly on Firefox.
    Firefox is the only one I use, if the site doesn't work properly with it then it's not standards compliant which makes it even more blacklisted as far as I'm concerned, did go post on the other one though, was already registered there, simply forgot it's existance for a while, thx for reminding me btw

  6. #186
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Managed to get the mantissa closer to being correct in the instances where it was incorrect:
    Code:
    make check.run
    ...
    Running suite(s): ALU
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 1, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 -0002 01111111101 0101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 -0002 01111111101 0101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 2, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 -0001 01111111110 0101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 -0001 01111111110 0101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 4, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0000 01111111111 0101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0000 01111111111 0101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 5, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0000 01111111111 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0000 01111111111 1010101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 7, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0000 01111111111 0010101010101010101010101010101010101010101010101010
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 8, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 0101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 0101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 9, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 10, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 1010101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 11, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 1101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 1101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 13, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 0001010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 14, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 0010101010101010101010101010101010101010101010101010
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 16, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 17, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0110101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 18, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 19, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1001010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 20, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1010101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 21, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 22, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 23, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1110101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 25, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0000101010101010101010101010101010101010101010101010
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 26, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0001010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 28, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0010101010101010101010101010101010101010101010101010
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 29, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0011010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0011010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 31, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0100101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0100101010101010101010101010101010101010101010101010
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 32, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 33, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 0110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 34, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0110101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 35, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0111010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0111010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 36, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 37, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1000101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 38, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1001010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 39, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1010000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1010000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 40, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1010101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 41, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1011010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1011010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 42, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 43, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1100101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1100101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 44, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1101010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1101010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 45, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 46, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1110101010101010101010101010101010101010101010101000
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 47, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1111010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1111010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 49, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0000010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0000010101010101010101010101010101010101010101010100
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 50, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0000101010101010101010101010101010101010101010101010
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 52, _val = 3, (_EXP.upto = 63) - (_EXP.from = 52) = 11, (_MAN.upto = 52) - (_MAN.from = 0) = 52
    ../tests/check_alu.c:1467: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1468: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0001010101010101010101010101010101010101010101010100
    97%: Checks: 1877, Failures: 43, Errors: 0
    ../tests/check_alu.c:1477:F:Core:test_alup_div_floating:1: Assertion 'memcmp( &result, &expect, sizeof(double) ) == 0' failed
    ...
    Compilation finished successfully.
    Now in addition to the mantissa being incorrect the few incorrect exponents are illuding me, here's the current code:
    Code:
    int_t alup__div( alup_t _NUM, alup_t _VAL, void *_rem, void *_tmp )
    {
    	if ( alup_floating( _NUM ) || alup_floating( _VAL ) )
    	{
    		int_t ret;
    		alup_t _DST, _SRC, _DMAN, _SMAN;
    		ssize_t exp, dexp, sexp, dbias, sbias, dbits, sbits, bits, size;
    		bool_t dneg, sneg;
    		
    		/* Ensure dealing with just floats, impossible for both to take _tmp
    		 * given the above if statment */
    		
    		if ( alup_floating( _NUM ) )
    		{
    			_DST = _NUM;
    		}
    		else
    		{
    			bits = _NUM.upto - _NUM.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _DST, _tmp, size );
    			alup_mov( _DST, _NUM );
    		}
    		
    		if ( alup_floating( _VAL ) )
    		{
    			_SRC = _VAL;
    		}
    		else
    		{
    			bits = _VAL.upto - _VAL.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _SRC, _tmp, size );
    			alup_mov( _SRC, _VAL );
    		}
    		
    		dneg = alup_below0( _DST );
    		sneg = alup_below0( _SRC );
    		alub_set( _DST.data, _DST.upto - 1, dneg != sneg );
    		
    		dexp = alup_get_exponent( _DST );
    		sexp = alup_get_exponent( _SRC );
    		
    		if ( !dexp || !sexp )
    		{
    			_NUM.upto--;
    			alup_set( _NUM, 0 );
    			return 0;
    		}
    		
    		dbias = alup_get_exponent_bias( _DST );
    		dexp -= dbias;
    		
    		sbias = alup_get_exponent_bias( _DST );
    		sexp -= sbias;
    				
    		alup_init_mantissa( _DST, _DMAN );
    		alup_init_mantissa( _SRC, _SMAN );
    		
    		dbits = _DMAN.upto - _DMAN.from;
    		sbits = _SMAN.upto - _SMAN.from;
    		bits = LOWEST( dbits, sbits );
    		
    		_SMAN.from = _SMAN.upto - EITHER( sexp >= 0 && sexp < bits, sexp, bits );
    		
    		alub_set( _DMAN.data, _DMAN.upto, 1 );
    		alub_set( _SMAN.data, _SMAN.upto, 1 );
    		_DMAN.upto++;
    		_SMAN.upto++;
    		
    		ret = alup__div_int2int( _DMAN, _SMAN, _rem );
    		
    		/* We mangled this so restore it now */
    		alup_set_exponent( _SRC, sexp + sbias );
    
    #if 1
    		if ( ret == EOVERFLOW )
    		{
    			dexp--;
    			//alup__shr( _DMAN, 1 );
    			//alub_set( _DMAN.data, _DMAN.upto - 1, 1 );
    		}
    #endif
    		
    		exp = dexp - sexp;
    		if ( exp > dbias )
    		{	
    			/* Set infinity */
    			alup_set( _DMAN, 0 );
    			alup_set_exponent( _DST, (dbias << 1) | 1 );
    		}
    		else if ( exp <= (ssize_t)(_DMAN.upto - _DMAN.from) )
    		{
    			alub_t e = alup_end_bit( _DMAN );
    			exp = (_DMAN.upto - e.bit) - 1;
    			alup__shl( _DMAN, exp );
    			alup_set_exponent( _DST, (dexp - sexp) + dbias );
    		}	
    		else
    		{
    			alup_set_exponent( _DST, exp + dbias );
    		}
    		
    		_DMAN.upto--;
    		_SMAN.upto--;
    		
    		if ( alup_floating( _NUM ) )
    			return 0;
    			
    		return alup_mov( _NUM, _DST );
    	}
    	
    	return alup__div_int2int( _NUM, _VAL, _rem );
    }

  7. #187
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    This is now the closest I've gotten (code is uploaded):
    Code:
    make check.run
    ...
    Running suite(s): ALU
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 5, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0000 01111111111 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0000 01111111111 1010101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 7, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0000 01111111111 0010101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 9, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1000000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 10, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 1010101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 13, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 0001010101010101010101010101010101010101010101010101
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 14, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 0010101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 17, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0110101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 18, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1000000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 20, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1010101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 21, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1100000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 23, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1110101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 25, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0000101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 26, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0001010101010101010101010101010101010101010101010101
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 28, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0010101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 29, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0011010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0011010101010101010101010101010101010101010101010101
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 31, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0100101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0100101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 33, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 0110000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 34, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0110101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 36, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1000000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 37, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1000101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 39, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1010000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1010000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 40, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1010101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 42, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1100000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 43, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1100101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1100101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 45, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1110000000000000000000000000000000000000000000000000
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 46, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1110101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1110101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 49, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0000010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0000010101010101010101010101010101010101010101010101
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 50, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0000101010101010101010101010101010101010101010101010
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../src/alup.c:1702: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 52, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0001010101010101010101010101010101010101010101010101
    98%: Checks: 1877, Failures: 29, Errors: 0
    ../tests/check_alu.c:1475:F:Core:test_alup_div_floating:5: Assertion 'memcmp( &result, &expect, sizeof(double) ) == 0' failed
    ...
    I think it's just the normalisation stage that needs work now:
    Code:
    int_t alup__div( alup_t _NUM, alup_t _VAL, void *_rem, void *_tmp )
    {
    	if ( alup_floating( _NUM ) || alup_floating( _VAL ) )
    	{
    		int_t ret;
    		alup_t _DST, _SRC, _DMAN, _SMAN;
    		size_t exp_len, man_len;
    		ssize_t exp, dexp, sexp, dbias, sbias, dbits, sbits, bits, size;
    		bool_t dneg, sneg;
    		
    		/* Ensure dealing with just floats, impossible for both to take _tmp
    		 * given the above if statment */
    		
    		if ( alup_floating( _NUM ) )
    		{
    			_DST = _NUM;
    		}
    		else
    		{
    			bits = _NUM.upto - _NUM.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _DST, _tmp, size );
    			alup_mov( _DST, _NUM );
    		}
    		
    		if ( alup_floating( _VAL ) )
    		{
    			_SRC = _VAL;
    		}
    		else
    		{
    			bits = _VAL.upto - _VAL.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _SRC, _tmp, size );
    			alup_mov( _SRC, _VAL );
    		}
    		
    		dneg = alup_below0( _DST );
    		sneg = alup_below0( _SRC );
    		alub_set( _DST.data, _DST.upto - 1, dneg != sneg );
    		
    		dexp = alup_get_exponent( _DST );
    		sexp = alup_get_exponent( _SRC );
    		
    		if ( !dexp || !sexp )
    		{
    			_NUM.upto--;
    			alup_set( _NUM, 0 );
    			return 0;
    		}
    		
    		dbias = alup_get_exponent_bias( _DST );
    		dexp -= dbias;
    		
    		sbias = alup_get_exponent_bias( _DST );
    		sexp -= sbias;
    				
    		alup_init_mantissa( _DST, _DMAN );
    		alup_init_mantissa( _SRC, _SMAN );
    		
    		dbits = _DMAN.upto - _DMAN.from;
    		sbits = _SMAN.upto - _SMAN.from;
    		bits = LOWEST( dbits, sbits );
    		
    		exp_len = (_DST.upto - _DMAN.upto) - 1;
    		man_len = (_DMAN.upto - _DST.from);
    		_SMAN.from = _SMAN.upto - EITHER( sexp >= 0 && sexp < bits, sexp, bits );
    		
    		alub_set( _SMAN.data, _SMAN.upto, 1 );
    		_DMAN.upto = _DST.upto - 1;
    		_SMAN.upto++;
    		
    		alup__shl( _DMAN, exp_len - 1 );
    		alub_set( _DMAN.data, _DMAN.upto - 1, 1 );
    		ret = alup__div_int2int( _DMAN, _SMAN, _rem );
    		
    		/* We mangled this so restore it now */
    		alup_set_exponent( _SRC, sexp + sbias );
    
    #if 1
    		if ( ret == EOVERFLOW )
    		{
    			dexp--;
    			//alup__shr( _DMAN, 1 );
    			//alub_set( _DMAN.data, _DMAN.upto - 1, 1 );
    		}
    #endif
    		
    		exp = dexp - sexp;
    		if ( exp > dbias )
    		{	
    			alu_puts("Route 1");
    			/* Set infinity */
    			_DMAN.upto = (_DST.upto - exp_len) - 1;
    			alup_set( _DMAN, 0 );
    			alup_set_exponent( _DST, (dbias << 1) | 1 );
    		}
    		else if ( exp <= (ssize_t)(_DMAN.upto - _DMAN.from) )
    		{
    			alub_t e = alup_end_bit( _DMAN );
    			ssize_t pos = (_DMAN.upto - e.bit) - 1;
    			bool_t round = 0;
    			
    			if ( pos >= (exp_len-1) )
    			{
    				alu_puts("Route 2.1");
    				alup__shr( _DMAN, (exp_len - 1) );
    				//alup__shr( _DMAN, ((_DMAN.upto - _DST.from) - pos) );
    			}
    			else
    			{
    				alu_puts("Route 2.2");
    				alup__shr( _DMAN, (exp_len - pos) - 1 );
    				if ( round )
    				{
    					alup_inc( _DMAN );
    				}
    			}
    			alup_set_exponent( _DST, exp + dbias );
    		}	
    		else
    		{
    			alu_puts("Route 3");
    			alup_set_exponent( _DST, exp + dbias );
    		}
    		
    		if ( alup_floating( _NUM ) )
    			return 0;
    			
    		return alup_mov( _NUM, _DST );
    	}
    	
    	return alup__div_int2int( _NUM, _VAL, _rem );
    }

  8. #188
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Fixed the mantissa part, now it's just the occasional exponent that needs fixing:
    Code:
    make check.run
    ...
    Running suite(s): ALU
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 7, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0000 01111111111 0010101010101010101010101010101010101010101010101011
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 9, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0001 10000000000 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 1000000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 13, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 0001010101010101010101010101010101010101010101010101
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 14, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0001 10000000000 0010101010101010101010101010101010101010101010101011
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 18, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1000000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 21, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0002 10000000001 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 1100000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 25, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0000101010101010101010101010101010101010101010101011
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 26, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0001010101010101010101010101010101010101010101010101
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 28, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0010101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0010101010101010101010101010101010101010101010101011
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 29, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0011010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0011010101010101010101010101010101010101010101010101
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 31, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0100101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0002 10000000001 0100101010101010101010101010101010101010101010101011
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 33, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 0110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 0110000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 36, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1000000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 39, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1010000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1010000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 42, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1100000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1100000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 45, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0003 10000000010 1110000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0004 10000000011 1110000000000000000000000000000000000000000000000000
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 49, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0000010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0000010101010101010101010101010101010101010101010101
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 50, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0000101010101010101010101010101010101010101010101011
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0000101010101010101010101010101010101010101010101011
    ../src/alup.c:1727: alup__div() 'Route 2.2'
    ...
    ../tests/check_alu.c:1456: test_alup_div_floating_fn() _num = 52, _val = 3, exp length = 11, man length = 52
    ../tests/check_alu.c:1465: test_alup_div_floating_fn() _EXPECT = 0 +0004 10000000011 0001010101010101010101010101010101010101010101010101
    ../tests/check_alu.c:1466: test_alup_div_floating_fn() _RESULT = 0 +0003 10000000010 0001010101010101010101010101010101010101010101010101
    98%: Checks: 1877, Failures: 19, Errors: 0
    ../tests/check_alu.c:1475:F:Core:test_alup_div_floating:7: Assertion 'memcmp( &result, &expect, sizeof(double) ) == 0' failed
    ...
    Compilation finished successfully.
    Code:
    Code:
    int_t alup__div( alup_t _NUM, alup_t _VAL, void *_rem, void *_tmp )
    {
    	if ( alup_floating( _NUM ) || alup_floating( _VAL ) )
    	{
    		int_t ret;
    		alup_t _DST, _SRC, _DMAN, _SMAN;
    		size_t exp_len, man_len;
    		ssize_t exp, dexp, sexp, dbias, sbias, dbits, sbits, bits, size;
    		bool_t dneg, sneg;
    		
    		/* Ensure dealing with just floats, impossible for both to take _tmp
    		 * given the above if statment */
    		
    		if ( alup_floating( _NUM ) )
    		{
    			_DST = _NUM;
    		}
    		else
    		{
    			bits = _NUM.upto - _NUM.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _DST, _tmp, size );
    			alup_mov( _DST, _NUM );
    		}
    		
    		if ( alup_floating( _VAL ) )
    		{
    			_SRC = _VAL;
    		}
    		else
    		{
    			bits = _VAL.upto - _VAL.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _SRC, _tmp, size );
    			alup_mov( _SRC, _VAL );
    		}
    		
    		dneg = alup_below0( _DST );
    		sneg = alup_below0( _SRC );
    		alub_set( _DST.data, _DST.upto - 1, dneg != sneg );
    		
    		dexp = alup_get_exponent( _DST );
    		sexp = alup_get_exponent( _SRC );
    		
    		if ( !dexp || !sexp )
    		{
    			_NUM.upto--;
    			alup_set( _NUM, 0 );
    			return 0;
    		}
    		
    		dbias = alup_get_exponent_bias( _DST );
    		dexp -= dbias;
    		
    		sbias = alup_get_exponent_bias( _DST );
    		sexp -= sbias;
    				
    		alup_init_mantissa( _DST, _DMAN );
    		alup_init_mantissa( _SRC, _SMAN );
    		
    		dbits = _DMAN.upto - _DMAN.from;
    		sbits = _SMAN.upto - _SMAN.from;
    		bits = LOWEST( dbits, sbits );
    		
    		exp_len = (_DST.upto - _DMAN.upto) - 1;
    		man_len = (_DMAN.upto - _DST.from);
    		_SMAN.from = _SMAN.upto - EITHER( sexp >= 0 && sexp < bits, sexp, bits );
    		
    		alub_set( _SMAN.data, _SMAN.upto, 1 );
    		_DMAN.upto = _DST.upto - 1;
    		_SMAN.upto++;
    		
    		alup__shl( _DMAN, exp_len - 1 );
    		alub_set( _DMAN.data, _DMAN.upto - 1, 1 );
    		ret = alup__div_int2int( _DMAN, _SMAN, _rem );
    		
    		/* We mangled this so restore it now */
    		alup_set_exponent( _SRC, sexp + sbias );
    
    #if 0
    		if ( ret == EOVERFLOW )
    		{
    			dexp--;
    			//alup__shr( _DMAN, 1 );
    			//alub_set( _DMAN.data, _DMAN.upto - 1, 1 );
    		}
    #endif
    		
    		exp = dexp - sexp;
    		if ( exp > dbias )
    		{	
    			alu_puts("Route 1");
    			/* Set infinity */
    			_DMAN.upto = (_DST.upto - exp_len) - 1;
    			alup_set( _DMAN, 0 );
    			alup_set_exponent( _DST, (dbias << 1) | 1 );
    		}
    		else if ( exp <= (ssize_t)(_DMAN.upto - _DMAN.from) )
    		{
    			/* Normalise */
    			alub_t
    				final = alup_final_one( _DMAN )
    				, first = alup_first_one( _DMAN );
    			ssize_t pos = (_DMAN.upto - final.bit) - 1;
    			bool_t round = (first.bit - _DST.from < exp_len);
    			
    			if ( pos >= (exp_len-1) )
    			{
    				alu_puts("Route 2.1");
    				alup__shr( _DMAN, (exp_len - 1) );
    				//alup__shr( _DMAN, ((_DMAN.upto - _DST.from) - pos) );
    			}
    			else
    			{
    				alu_puts("Route 2.2");
    				
    				alup__shr( _DMAN, (exp_len - pos) - 2 );
    				
    				if ( round )
    				{
    					--exp;
    					alup_inc( _DMAN );
    				}
    				
    				alup__shr( _DMAN, 1 );
    			}
    			alup_set_exponent( _DST, exp + dbias );
    		}	
    		else
    		{
    			alu_puts("Route 3");
    			alup__shr( _DMAN, (exp_len - 1) );
    			alup_set_exponent( _DST, exp + dbias );
    		}
    		
    		if ( alup_floating( _NUM ) )
    			return 0;
    			
    		return alup_mov( _NUM, _DST );
    	}
    	
    	return alup__div_int2int( _NUM, _VAL, _rem );
    }

  9. #189
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    be starting work in a few minutes so can't respond quickly, managed to fix the division exponent as well, already uploaded so if you wany to try various tests or design better tests feel free to do so

  10. #190
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Welp the new more thorough tests revealed a bug as I was expecting in FPN multiplication, division remains to be seen as the tests now stop on the 1st error, I'm not getting any ideas presently so will just post the code & output, upload the code and pray either God gives me an idea for fixing it or someone else gets given the idea and they post it.
    Code:
    Code:
    int_t alup__mul( alup_t _NUM, alup_t _VAL, void *_cpy, void *_tmp )
    {
    	if ( alup_floating( _NUM ) || alup_floating( _VAL ) )
    	{
    		int_t ret;
    		alup_t _DST, _SRC, _DMAN, _SMAN;
    		ssize_t exp, dexp, sexp, dbias, sbias, dbits, sbits, bits, size;
    		bool_t dneg, sneg;
    		
    		/* Ensure dealing with just floats, impossible for both to take _tmp
    		 * given the above if statment */
    		
    		if ( alup_floating( _NUM ) )
    		{
    			_DST = _NUM;
    		}
    		else
    		{
    			bits = _NUM.upto - _NUM.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _DST, _tmp, size );
    			alup_mov( _DST, _NUM );
    		}
    		
    		if ( alup_floating( _VAL ) )
    		{
    			_SRC = _VAL;
    		}
    		else
    		{
    			bits = _VAL.upto - _VAL.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _SRC, _tmp, size );
    			alup_mov( _SRC, _VAL );
    		}
    		
    		dneg = alup_below0( _DST );
    		sneg = alup_below0( _SRC );
    		alub_set( _DST.data, _DST.upto - 1, dneg != sneg );
    		
    		dexp = alup_get_exponent( _DST );
    		sexp = alup_get_exponent( _SRC );
    		
    		if ( !dexp || !sexp )
    		{
    			_NUM.upto--;
    			alup_set( _NUM, 0 );
    			return 0;
    		}
    		
    		dbias = alup_get_exponent_bias( _DST );
    		dexp -= dbias;
    		
    		sbias = alup_get_exponent_bias( _DST );
    		sexp -= sbias;
    		
    		exp = dexp + sexp;
    				
    		alup_init_mantissa( _DST, _DMAN );
    		alup_init_mantissa( _SRC, _SMAN );
    		
    		alub_set( _DMAN.data, _DMAN.upto, 1 );
    		alub_set( _SMAN.data, _SMAN.upto, 1 );
    		_DMAN.upto++;
    		_SMAN.upto++;
    		
    		dbits = _DMAN.upto - _DMAN.from;
    		sbits = _SMAN.upto - _SMAN.from;
    		bits = LOWEST( dbits, sbits );
    		
    		_DMAN.from = _DMAN.upto - EITHER( dexp >= 0 && dexp < dbits, dexp, dbits );
    		_SMAN.from = _SMAN.upto - EITHER( sexp >= 0 && sexp < sbits, sexp, sbits );
    		
    		ret = alup__mul_int2int( _DMAN, _SMAN, _cpy );
    		
    		/* We mangled this so restore it now */
    		alup_set_exponent( _SRC, sexp + sbias );
    		
    		/* Multiplication prep may have changed this value, ensure is what it
    		 * started as before using it any more */
    		_DMAN.from = _DST.from;
    		
    		if ( exp > dbias )
    		{	
    			/* Set infinity */
    			_DMAN.upto--;
    			alup_set_exponent( _DST, (dbias << 1) | 1 );
    			alup_set( _DMAN, 0 );
    		}
    		else
    		{
    			/* Normalise */
    			alub_t final = alup_final_one( _DMAN );
    			size_t pos = (_DMAN.upto - final.bit) - 1;
    			
    			if ( ret == EOVERFLOW )
    			{
    				exp++;
    				alup__shr( _DMAN, pos );
    				alub_set( _DMAN.data, _DMAN.upto - 2, 1 );
    			}
    			
    			alup_set_exponent( _DST, exp + dbias );
    		}
    		
    		if ( alup_floating( _NUM ) )
    			return 0;
    			
    		return alup_mov( _NUM, _DST );
    	}
    	
    	return alup__mul_int2int( _NUM, _VAL, _cpy );
    }
    ...
    const int per_func = LDBL_MANT_DIG;
    bool_t stop_checks = false;
    
    START_TEST( test_alup__math_floating )
    {
    	if ( !stop_checks )
    	{
    		ck_assert( alu_upto(alu) > 0 );
    		size_t func = _i / per_func;
    		double tmp_value1, tmp_value2
    			, _value1 = _i
    			, _value2 = _i % per_func
    			, expect = _value1
    			, result = _value1;
    		alup_t _RESULT, _VALUE2;
    		
    		alup_init_floating( _RESULT, &result, sizeof(double) );
    		alup_init_floating( _VALUE2, &_value2, sizeof(double) );
    		
    		expect = flt_math[func]( _value1, _value2 );
    		alup__math[func]( _RESULT, _VALUE2, &tmp_value1, &tmp_value2 );
    		
    		if ( memcmp( &result, &expect, sizeof(double) ) != 0 )
    		{
    			alup_t _EXP, _MAN, _EXPECT, _VALUE1;
    			
    			alup_init_floating( _EXPECT, &expect, sizeof(double) );
    			alup_init_floating( _VALUE1, &_value1, sizeof(double) );
    			alup_init_exponent( _VALUE1, _EXP );
    			alup_init_mantissa( _VALUE1, _MAN );
    			
    			alu_printf
    			(
    				"%f %c %f = %f, got %f, exp_dig = %zu, man_dig = %zu"
    				, _value1
    				, op_math[func]()
    				, _value2
    				, expect
    				, result
    				, _EXP.upto - _EXP.from
    				, _MAN.upto - _MAN.from
    			);
    			
    			alup_print( _VALUE1, 0, 1 );
    			alup_print( _VALUE2, 0, 1 );
    			alup_print( _EXPECT, 0, 1 );
    			alup_print( _RESULT, 0, 1 );
    			stop_checks = true;
    		}
    		
    		ck_assert( memcmp( &result, &expect, sizeof(double) ) == 0 );
    	}
    }
    END_TEST
    Output:
    Code:
    make check.run
    ...
    Running suite(s): ALU
    ../tests/check_alu.c:1151: test_alup__math_floating_fn() 131.000000 * 3.000000 = 393.000000, got 262.000000, exp_dig = 11, man_dig = 52
    ../tests/check_alu.c:1163: test_alup__math_floating_fn() _VALUE1 = 0 +0007 10000000110 0000011000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1164: test_alup__math_floating_fn() _VALUE2 = 0 +0001 10000000000 1000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1165: test_alup__math_floating_fn() _EXPECT = 0 +0008 10000000111 1000100100000000000000000000000000000000000000000000
    ../tests/check_alu.c:1166: test_alup__math_floating_fn() _RESULT = 0 +0008 10000000111 0000011000000000000000000000000000000000000000000000
    99%: Checks: 1815, Failures: 1, Errors: 0
    ...

  11. #191
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Managed to fix it:
    Code:
    int_t alup__mul( alup_t _NUM, alup_t _VAL, void *_cpy, void *_tmp )
    {
    	if ( alup_floating( _NUM ) || alup_floating( _VAL ) )
    	{
    		int_t ret;
    		alup_t _DST, _SRC, _DMAN, _SMAN;
    		ssize_t exp, dexp, sexp, dbias, sbias, dbits, sbits, bits, size;
    		bool_t dneg, sneg;
    		ssize_t ddiff = 0, sdiff = 0;
    		size_t man_upto;
    		alub_t final, prior;
    		
    		/* Ensure dealing with just floats, impossible for both to take _tmp
    		 * given the above if statment */
    		
    		if ( alup_floating( _NUM ) )
    		{
    			_DST = _NUM;
    		}
    		else
    		{
    			bits = _NUM.upto - _NUM.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _DST, _tmp, size );
    			alup_mov( _DST, _NUM );
    		}
    		
    		if ( alup_floating( _VAL ) )
    		{
    			_SRC = _VAL;
    		}
    		else
    		{
    			bits = _VAL.upto - _VAL.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _SRC, _tmp, size );
    			alup_mov( _SRC, _VAL );
    		}
    		
    		dneg = alup_below0( _DST );
    		sneg = alup_below0( _SRC );
    		
    		dexp = alup_get_exponent( _DST );
    		sexp = alup_get_exponent( _SRC );
    		
    		if ( !dexp || !sexp )
    		{
    			_NUM.upto--;
    			alup_set( _NUM, 0 );
    			alub_set( _DST.data, _DST.upto - 1, dneg != sneg );
    			return 0;
    		}
    		
    		dbias = alup_get_exponent_bias( _DST );
    		dexp -= dbias;
    		
    		sbias = alup_get_exponent_bias( _DST );
    		sexp -= sbias;
    		
    		exp = dexp + sexp;
    				
    		alup_init_mantissa( _DST, _DMAN );
    		alup_init_mantissa( _SRC, _SMAN );
    		
    		dbits = _DMAN.upto - _DMAN.from;
    		sbits = _SMAN.upto - _SMAN.from;
    		bits = LOWEST( dbits, sbits );
    		
    		ddiff = EITHER( dexp >= 0 && dexp < dbits, dexp, dbits );
    		sdiff = EITHER( sexp >= 0 && sexp < sbits, sexp, sbits );
    		prior = alub( _DST.data, _DST.upto - 1 );
    		*(prior.ptr) &= ~(prior.mask);
    		alup_set_exponent( _DST, 0 );
    		
    		alub_set( _DST.data, _DMAN.upto, 1 );
    		alub_set( _SRC.data, _SMAN.upto, 1 );
    		
    		man_upto = _DMAN.upto;
    		
    		_SMAN.from = _SMAN.upto - sdiff;
    		_DMAN.upto = _DST.upto;
    		_SMAN.upto++;
    		
    		alup__shr( _DMAN, dbits - ddiff );
    		prior = alup_final_one( _DMAN );
    		
    		ret = alup__mul_int2int( _DMAN, _SMAN, _cpy );
    		
    		/* We mangled this so restore it now */
    		alup_set_exponent( _SRC, sexp + sbias );
    		
    		if ( exp >= dbias )
    		{	
    			/* Set infinity */
    			alup_init_mantissa( _DST, _DMAN );
    			
    			alup_set( _DMAN, 0 );
    			alup_set_exponent( _DST, (dbias << 1) | 1 );
    		}
    		else
    		{	
    			final = alup_final_one( _DMAN );
    			_DMAN.upto = man_upto;
    			
    			if ( final.bit >= prior.bit )
    			{
    				/* Normalise */
    				size_t mov = _DMAN.upto - final.bit;
    				size_t add = final.bit - prior.bit;
    				
    				exp = dexp + add;
    				alup__shl( _DMAN, mov );
    			}
    			else if ( ret == EOVERFLOW )
    			{
    				exp++;
    				alup__shr( _DMAN, 1 );
    				alub_set( _DMAN.data, _DMAN.upto - 1, 1 );
    			}
    			
    			alup_set_exponent( _DST, exp + dbias );
    		}
    		
    		alub_set( _DST.data, _DST.upto - 1, dneg != sneg );
    		
    		if ( alup_floating( _NUM ) )
    			return 0;
    			
    		return alup_mov( _NUM, _DST );
    	}
    	
    	return alup__mul_int2int( _NUM, _VAL, _cpy );
    }
    Now I just need to track down the source of a bug revealed by the more thorough tests on FPN division, I'll think about it either tomorrow or Tuesday, in mean time I'll leave the output and code here in case someone
    gets impatient:
    Code:
    make check.run
    ...
    Running suite(s): ALU
    ../tests/check_alu.c:1151: test_alup__math_floating_fn() exp_dig = 11, man_dig = 52, 1.000000 / 1.000000 = 1.000000, got 2.000000
    ../tests/check_alu.c:1163: test_alup__math_floating_fn() _VALUE2 = 0 +0000 01111111111 0000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1164: test_alup__math_floating_fn() _EXPECT = 0 +0000 01111111111 0000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:1165: test_alup__math_floating_fn() _RESULT = 0 +0001 10000000000 0000000000000000000000000000000000000000000000000000
    99%: Checks: 1815, Failures: 1, Errors: 0
    ...
    Compilation finished successfully.
    Code:
    int_t alup__div( alup_t _NUM, alup_t _VAL, void *_rem, void *_tmp )
    {
    	if ( alup_floating( _NUM ) || alup_floating( _VAL ) )
    	{
    		alup_t _DST, _SRC, _DMAN, _SMAN;
    		size_t exp_len;
    		ssize_t exp, dexp, sexp, dbias, sbias, dbits, sbits, bits, size;
    		bool_t dneg, sneg;
    		
    		/* Ensure dealing with just floats, impossible for both to take _tmp
    		 * given the above if statment */
    		
    		if ( alup_floating( _NUM ) )
    		{
    			_DST = _NUM;
    		}
    		else
    		{
    			bits = _NUM.upto - _NUM.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _DST, _tmp, size );
    			alup_mov( _DST, _NUM );
    		}
    		
    		if ( alup_floating( _VAL ) )
    		{
    			_SRC = _VAL;
    		}
    		else
    		{
    			bits = _VAL.upto - _VAL.from;
    			size = BITS2SIZE( bits );
    			alup_init_floating( _SRC, _tmp, size );
    			alup_mov( _SRC, _VAL );
    		}
    		
    		dneg = alup_below0( _DST );
    		sneg = alup_below0( _SRC );
    		alub_set( _DST.data, _DST.upto - 1, dneg != sneg );
    		
    		dexp = alup_get_exponent( _DST );
    		sexp = alup_get_exponent( _SRC );
    		
    		if ( !dexp || !sexp )
    		{
    			_NUM.upto--;
    			alup_set( _NUM, 0 );
    			return 0;
    		}
    		
    		dbias = alup_get_exponent_bias( _DST );
    		dexp -= dbias;
    		
    		sbias = alup_get_exponent_bias( _DST );
    		sexp -= sbias;
    				
    		alup_init_mantissa( _DST, _DMAN );
    		alup_init_mantissa( _SRC, _SMAN );
    		
    		dbits = _DMAN.upto - _DMAN.from;
    		sbits = _SMAN.upto - _SMAN.from;
    		bits = LOWEST( dbits, sbits );
    		
    		exp_len = (_DST.upto - _DMAN.upto) - 1;
    		_SMAN.from = _SMAN.upto - EITHER( sexp >= 0 && sexp < bits, sexp, bits );
    		
    		alub_set( _SMAN.data, _SMAN.upto, 1 );
    		_DMAN.upto = _DST.upto - 1;
    		_SMAN.upto++;
    		
    		alup__shl( _DMAN, exp_len - 1 );
    		alub_set( _DMAN.data, _DMAN.upto - 1, 1 );
    		(void)alup__div_int2int( _DMAN, _SMAN, _rem );
    		
    		/* We mangled this so restore it now */
    		alup_set_exponent( _SRC, sexp + sbias );
    		
    		exp = dexp - sexp;
    		
    		if ( exp > dbias )
    		{	
    			alu_puts("Route 1");
    			/* Set infinity */
    			_DMAN.upto = (_DST.upto - exp_len) - 1;
    			alup_set( _DMAN, 0 );
    			alup_set_exponent( _DST, (dbias << 1) | 1 );
    		}
    		else if ( exp <= (ssize_t)(_DMAN.upto - _DMAN.from) )
    		{
    			/* Normalise */
    			alub_t final = alup_final_one( _DMAN )
    				, first = alup_first_one( _DMAN );
    			size_t pos = (_DMAN.upto - final.bit) - 1;
    			bool_t round = (first.bit - _DST.from < exp_len);
    			
    			if ( pos >= (exp_len-1) )
    			{
    				//alu_puts("Route 2.1");
    				alup__shr( _DMAN, (exp_len - 1) );
    				//alup__shr( _DMAN, ((_DMAN.upto - _DST.from) - pos) );
    			}
    			else
    			{
    				//alu_puts("Route 2.2");
    				
    				alup__shr( _DMAN, (exp_len - pos) - 2 );
    				exp -= (pos-1);
    				
    				if ( round )
    				{
    					alup_inc( _DMAN );
    				}
    				
    				alup__shr( _DMAN, 1 );
    			}
    			alup_set_exponent( _DST, exp + dbias );
    		}	
    		else
    		{
    			//alu_puts("Route 3");
    			alup__shr( _DMAN, (exp_len - 1) );
    			alup_set_exponent( _DST, exp + dbias );
    		}
    		
    		if ( alup_floating( _NUM ) )
    			return 0;
    			
    		return alup_mov( _NUM, _DST );
    	}
    	
    	return alup__div_int2int( _NUM, _VAL, _rem );
    }
    (Did remember to upload this time unlike what I said a couple posts ago when I found the bug in FPN multiplication)

  12. #192
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    I managed to fix it, turned out I had to use 2 different variables with a common value difference of 1, tried just 1 value and subtracting 1 but for whatever reason it refuses accuracy when only one variable is used, for now I'll put that mystery on the back burner, instead I'd like peops to take a look at the below and suggest any more thorough tests they have in mind:
    Code:
    typedef int_t (*func_alup__math_t)
    (
    	alup_t _NUM
    	, alup_t _VAL
    	, void *cpy
    	, void *tmp
    );
    
    func_alup__math_t alup__math[] =
    {
    	alup__add
    	, alup__sub
    	, alup__mul
    	, alup__div
    	, NULL
    };
    
    int op_add() { return '+'; }
    int op_sub() { return '-'; }
    int op_mul() { return '*'; }
    int op_div() { return '/'; }
    int op_rem() { return '%'; }
    
    typedef int (*func_op_math_t)();
    
    func_op_math_t op_math[] =
    {
    	op_add
    	, op_sub
    	, op_mul
    	, op_div
    	, op_rem
    	, NULL
    };
    
    ulong_t int_add( ulong_t num, ulong_t val ) { return num + val; }
    ulong_t int_sub( ulong_t num, ulong_t val ) { return num - val; }
    ulong_t int_mul( ulong_t num, ulong_t val ) { return num * val; }
    ulong_t int_div( ulong_t num, ulong_t val ) { return val ? num / val : 0; }
    ulong_t int_rem( ulong_t num, ulong_t val ) { return val ? num % val : num; }
    
    typedef ulong_t (*func_int_math_t)( ulong_t num, ulong_t val );
    
    func_int_math_t int_math[] =
    {
    	int_add
    	, int_sub
    	, int_mul
    	, int_div
    	, int_rem
    	, NULL
    };
    
    double flt_add( double num, double val ) { return num + val; }
    double flt_sub( double num, double val ) { return num - val; }
    double flt_mul( double num, double val ) { return num * val; }
    double flt_div( double num, double val ) { return val ? num / val : 0; }
    //double flt_rem( double num, double val ) { return val ? num % val : num; }
    
    typedef double (*func_flt_math_t)( double num, double val );
    
    func_flt_math_t flt_math[] =
    {
    	flt_add
    	, flt_sub
    	, flt_mul
    	, flt_div
    	, NULL
    };
    
    const int per_func = LDBL_MANT_DIG;
    bool_t stop_checks = false;
    
    START_TEST( test_alup__math_floating )
    {
    	if ( !stop_checks )
    	{
    		ck_assert( alu_upto(alu) > 0 );
    		size_t func = _i / per_func;
    		double extra1, extra2
    			, value1 = _i
    			, value2 = _i % per_func
    			, expect, result;
    		alup_t _RESULT, _VALUE2;
    		
    		alup_init_floating( _RESULT, &result, sizeof(double) );
    		alup_init_floating( _VALUE2, &value2, sizeof(double) );
    		
    		result = value2;
    		expect = flt_math[func]( value2, value2 );
    		alup__math[func]( _RESULT, _VALUE2, &extra1, &extra2 );
    		
    		if ( memcmp( &result, &expect, sizeof(double) ) != 0 )
    		{
    			alup_t _EXP, _MAN, _EXPECT, _VALUE1;
    			
    			alup_init_floating( _EXPECT, &expect, sizeof(double) );
    			alup_init_floating( _VALUE1, &value1, sizeof(double) );
    			alup_init_exponent( _VALUE1, _EXP );
    			alup_init_mantissa( _VALUE1, _MAN );
    			
    			alu_printf
    			(
    				"exp_dig = %zu, man_dig = %zu, %f %c %f = %f, got %f"
    				, _EXP.upto - _EXP.from
    				, _MAN.upto - _MAN.from
    				, value2
    				, op_math[func]()
    				, value2
    				, expect
    				, result
    			);
    			
    			//alup_print( _VALUE2, 0, 1 );
    			alup_print( _EXPECT, 0, 1 );
    			alup_print( _RESULT, 0, 1 );
    			stop_checks = true;
    		}
    		
    		ck_assert( memcmp( &result, &expect, sizeof(double) ) == 0 );
    		
    		result = value1;
    		expect = flt_math[func]( value1, value2 );
    		alup__math[func]( _RESULT, _VALUE2, &extra1, &extra2 );
    		
    		if ( memcmp( &result, &expect, sizeof(double) ) != 0 )
    		{
    			alup_t _EXP, _MAN, _EXPECT, _VALUE1;
    			
    			alup_init_floating( _EXPECT, &expect, sizeof(double) );
    			alup_init_floating( _VALUE1, &value1, sizeof(double) );
    			alup_init_exponent( _VALUE1, _EXP );
    			alup_init_mantissa( _VALUE1, _MAN );
    			
    			alu_printf
    			(
    				"exp_dig = %zu, man_dig = %zu, %f %c %f = %f, got %f"
    				, _EXP.upto - _EXP.from
    				, _MAN.upto - _MAN.from
    				, value1
    				, op_math[func]()
    				, value2
    				, expect
    				, result
    			);
    
    #if 0	
    			alup_print( _VALUE1, 0, 1 );
    			alup_print( _VALUE2, 0, 1 );
    #endif
    			alup_print( _EXPECT, 0, 1 );
    			alup_print( _RESULT, 0, 1 );
    			stop_checks = true;
    		}
    		
    		ck_assert( memcmp( &result, &expect, sizeof(double) ) == 0 );
    	}
    }
    END_TEST

  13. #193
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Welp the lack of replies tells me one of these things:

    1. No one had any ideas for more thorough testing (doubtful)
    2. None of their ideas flagged any bugs (assumes people actually downloaded the project and tried those ideas, doubt that also)
    3. No one was interested (somewhat doubtful)
    4. No one was interested enough to actually post something (strongly suspect)

    So I'm just gonna get on with the cleaning up current integer tests so they look exactly as the FPN tests does, I'll then move onto transforming to/from text and finally begin expression handling, I can then fob most of that stuff to the alu library when gasp is reading cheat files with specific width values or doing comparisons of process memory to expected values of specific width

  14. #194
    Registered User
    Join Date
    Sep 2020
    Posts
    55
    5. People might had an interest but couldn't build it Windows(possible)

  15. #195
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,174
    Quote Originally Posted by thmm View Post
    5. People might had an interest but couldn't build it Windows(possible)
    Ah, didn't think of that, unfortunately when I tried to setup a dual boot windows didn't want to install... despite being preinstalled when I 1st got the new computer, goes to show that windows is an old toy that should really be let go, next week when I have the time I'll try a vbox win7 install, at least that should run as expected

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can anyone help to spot mistake in the code
    By chess_queen in forum C Programming
    Replies: 1
    Last Post: 10-21-2012, 10:37 AM
  2. Can you spot my mistake?
    By Brewer in forum C Programming
    Replies: 13
    Last Post: 11-12-2006, 12:50 PM
  3. going to a certain spot in a file...
    By agerealm in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2002, 02:31 AM

Tags for this Thread