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/source/native/ref32/mul32.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 / source / native / ref32 / mul32.om` 88 lines ยท 1572 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note Native IEEE binary32 multiplication represented as bits; no host floating runtime. 3 note Round-to-nearest ties-to-even, gradual underflow, signed zeros and infinities. 4 note Canonical positive quiet NaN for every NaN result. Inputs are low32 bits. 5 fn mround x ulong shift ulong to ulong 6 if eq shift 0 7 ret x 8 end 9 if gt shift 63 10 ret 0 11 end 12 q = shr x shift 13 mask = sub shl 1 shift 1 14 r = and x mask 15 half = shl 1 sub shift 1 16 if or gt r half and eq r half ne and q 1 0 17 q = add q 1 18 end 19 ret q 20 end 21 fn mul32 aa ulong bb ulong to ulong 22 a = and aa `4294967295` 23 b = and bb `4294967295` 24 sign = and xor a b `2147483648` 25 ea = long and shr a 23 255 26 eb = long and shr b 23 255 27 ma = and a `8388607` 28 mb = and b `8388607` 29 if or and eq ea 255 ne ma 0 and eq eb 255 ne mb 0 30 ret `2143289344` 31 end 32 if or eq ea 255 eq eb 255 33 if or eq and a `2147483647` 0 eq and b `2147483647` 0 34 ret `2143289344` 35 end 36 ret or sign `2139095040` 37 end 38 if or eq and a `2147483647` 0 eq and b `2147483647` 0 39 ret sign 40 end 41 if eq ea 0 42 ea = 1 43 while lt ma `8388608` 44 ma = shl ma 1 45 ea = sub ea 1 46 end 47 else 48 ma = or ma `8388608` 49 end 50 if eq eb 0 51 eb = 1 52 while lt mb `8388608` 53 mb = shl mb 1 54 eb = sub eb 1 55 end 56 else 57 mb = or mb `8388608` 58 end 59 product = mul ma mb 60 e = sub add ea eb 127 61 shift = long 23 62 if ge product `140737488355328` 63 shift = 24 64 e = add e 1 65 end 66 if lt e 1 67 shift = add shift sub 1 e 68 e = 0 69 end 70 q = mround product ulong shift 71 if eq e 0 72 if ge q `8388608` 73 e = 1 74 end 75 else 76 if ge q `16777216` 77 q = shr q 1 78 e = add e 1 79 end 80 end 81 if ge e 255 82 ret or sign `2139095040` 83 end 84 q = and q `8388607` 85 e = shl e 23 86 q = or q ulong e 87 ret or sign q 88 end