Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-train/blob/main/evidence/ECOSYSTEM6/ref32-review/add-focused.om # aien-train AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / evidence / ECOSYSTEM6 / ref32-review / add-focused.om` 149 lines ยท 2822 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note Native IEEE binary32 addition over bit patterns, RNE and gradual underflow. 3 note Canonical positive quiet NaN; no foreign floating runtime or compiler f32 type. 4 fn ajam x ulong n ulong to ulong 5 if eq n 0 6 ret x 7 end 8 if ge n 64 9 if ne x 0 10 ret 1 11 end 12 ret 0 13 end 14 q = shr x n 15 mask = sub shl 1 n 1 16 if ne and x mask 0 17 q = or q 1 18 end 19 ret q 20 end 21 fn add32 aa ulong bb ulong to ulong 22 a = and aa `4294967295` 23 b = and bb `4294967295` 24 if or gt and a `2147483647` `2139095040` gt and b `2147483647` `2139095040` 25 ret `2143289344` 26 end 27 if lt and a `2147483647` and b `2147483647` 28 t = a 29 a = b 30 b = t 31 end 32 if eq and a `2147483647` `2139095040` 33 if and eq and b `2147483647` `2139095040` ne and xor a b `2147483648` 0 34 ret `2143289344` 35 end 36 ret a 37 end 38 if eq and b `2147483647` 0 39 if eq and a `2147483647` 0 40 ret and and a b `2147483648` 41 end 42 ret a 43 end 44 sign = and a `2147483648` 45 ea = and shr a 23 255 46 eb = and shr b 23 255 47 ma = and a `8388607` 48 mb = and b `8388607` 49 if eq ea 0 50 ea = 1 51 else 52 ma = or ma `8388608` 53 end 54 if eq eb 0 55 eb = 1 56 else 57 mb = or mb `8388608` 58 end 59 ma = shl ma 3 60 mb = shl mb 3 61 mb = ajam mb sub ea eb 62 if eq and xor a b `2147483648` 0 63 ma = add ma mb 64 if ge ma `134217728` 65 ma = ajam ma 1 66 ea = add ea 1 67 end 68 else 69 ma = sub ma mb 70 if eq ma 0 71 ret 0 72 end 73 while and lt ma `67108864` gt ea 1 74 ma = shl ma 1 75 ea = sub ea 1 76 end 77 end 78 q = shr ma 3 79 r = and ma 7 80 if gt r 4 81 q = add q 1 82 else 83 if eq r 4 84 if ne and q 1 0 85 q = add q 1 86 end 87 end 88 end 89 if ge q `16777216` 90 q = shr q 1 91 ea = add ea 1 92 end 93 if ge ea 255 94 ret or sign `2139095040` 95 end 96 if lt q `8388608` 97 ea = 0 98 end 99 q = and q `8388607` 100 ea = shl ea 23 101 q = or q ea 102 ret or sign q 103 end 104 note SPDX-License-Identifier: AGPL-3.0-only 105 global failed ulong 1 106 global tested ulong 1 107 global line uchar 48 108 fn report ok bool to void 109 id = add get tested 0 1 110 put tested 0 id 111 put line 0 48 112 put line 1 uchar add 48 rem div id 100 10 113 put line 2 uchar add 48 rem div id 10 10 114 put line 3 uchar add 48 rem id 10 115 put line 4 32 116 put line 5 48 117 if not ok 118 put line 5 49 119 put failed 0 add get failed 0 1 120 end 121 put line 6 10 122 w = write 1 line 0 7 123 if ne w 7 124 exit 74 125 end 126 end 127 note Native RNE addition boundary cases, expected IEEE binary32 bits. 128 fn main to int 129 report eq add32 `1065353216` `1065353216` `1073741824` 130 report eq add32 `3212836864` `1065353216` 0 131 report eq add32 `2147483648` `2147483648` `2147483648` 132 report eq add32 `2147483648` 0 0 133 report eq add32 `2139095040` `4286578688` `2143289344` 134 report eq add32 `2139095040` `1065353216` `2139095040` 135 report eq add32 `2143289345` `1065353216` `2143289344` 136 report eq add32 1 1 2 137 report eq add32 `8388607` 1 `8388608` 138 report eq add32 `8388608` `2155872255` 1 139 report eq add32 `2139095039` `2139095039` `2139095040` 140 report eq add32 `1065353216` `864026624` `1065353216` 141 report eq add32 `1065353217` `864026624` `1065353218` 142 report eq add32 `1065353216` `3011510272` `1065353215` 143 report eq add32 `1065353216` 1 `1065353216` 144 report eq add32 1 `2147483649` 0 145 if ne get failed 0 0 146 ret 1 147 end 148 ret 0 149 end