From: Ed B. <be...@mi...> - 2013-07-16 03:01:56
|
Frank Kotler wrote: > works fine. I have also confirmed that we can assemble his file by > increasing the value of DEADMAN_LIMIT in preproc.c to 1<<31. I don't > consider it a "bug" that needs to be "fixed", but I promised him I'd > discuss it with y'all. Any thoughts? Definitely nasm abuse. Tell the poster to break up the lines into human-sized chunks. A simple way to do this is to replace the ln_10_2() function with the following enhanced version (the four new lines are marked with # new line): import math def ieee754(x): import struct return hex(struct.unpack('>l', struct.pack('>f', x))[0]) def ln(x, n): ln_x = 0 for k in range(1, n): k = float(k) ln_x += float((1/(2*k-1)) * (((x-1)/(x+1))**(2*k-1))) return float(2*ln_x) def ln0_10_2(i): start = 0 step = 1 stop = 10**i n = 0 # new line with open('log_0x10.inc','w') as file: file.write('log2_table dd ') while (start != stop): start += step with open('log_0x10.inc','a') as file: if (n & 3) == 3: # new line file.write("\n dd "); # new line n += 1 # new line file.write('%s, ' % ieee754(math.log(start,2))) ln0_10_2(6) print ieee754(math.log(10**4,2)); ''' ln(x) = ln(a * 10 ^ i) x = a * 10 ^ i a = x / 10 ^ i 0.0005 = ''' |