shithub: mc

ref: b3526b5e8cc2f28b17096115524731afc254e02b
dir: /lib/math/test/atan-impl.myr/

View raw version
use std
use math
use testr

const main = {
	math.fptrap(false)
	testr.run([
		[.name="atan-01", .fn = atan01], /* atan, flt32 */
		[.name="atan-02", .fn = atan02], /* atan, flt64 */
		[.name="atan-03", .fn = atan03], /* atan2, flt32 */
		[.name="atan-04", .fn = atan04], /* atan2, flt64 */
		[.name="atan-05", .fn = atan05], /* atan, off-by-1-ulp quarantine */
		[.name="atan-06", .fn = atan06], /* atan2, off-by-1-ulp quarantine */
		[.name="atan-07", .fn = atan07], /* exhaustively test C */
		[.name="atan-08", .fn = atan08], /* NaN handling */
	][:])
}

const same32 = {a, b
	if a == b
		-> true
	;;

	if std.isnan(std.flt32frombits(a)) && std.isnan(std.flt32frombits(b))
		-> true
	;;

	-> false
}

const same64 = {a, b
	if a == b
		-> true
	;;

	if std.isnan(std.flt64frombits(a)) && std.isnan(std.flt64frombits(b))
		-> true
	;;

	-> false
}

const atan01 = {c
	var inputs : (uint32, uint32)[:] = [
		(0x00000000, 0x00000000),
		(0xec0c0000, 0xbfc90fdb),
		(0xd30d0000, 0xbfc90fdb),
		(0x4c120000, 0x3fc90fda),
		(0x0c010000, 0x0c010000),
		(0xc0070000, 0xbf9065b4),
		(0x3d8d6b23, 0x3d8d31c3),
		(0xbd8d6b23, 0xbd8d31c3),
		(0xbf000000, 0xbeed6338),
		(0xc1010000, 0xbfb94442),
	][:]

	for (x, y) : inputs
		var xf : flt32 = std.flt32frombits(x)
		var yf : flt32 = std.flt32frombits(y)
		var a1f : flt32 = math.atan(xf)
		var a2f : flt32 = math.atan2(xf, 1.0)
		var a1u : uint32 = std.flt32bits(a1f)
		var a2u : uint32 = std.flt32bits(a2f)
		testr.check(c, same32(a1u, a2u),
			"atan(0x{b=16,w=8,p=0}) = 0x{b=16,w=8,p=0}, but atan2(0x{b=16,w=8,p=0}, 1.0) = 0x{b=16,w=8,p=0}",
			x, a1u, x, a2u)

		testr.check(c, same32(a1u, y),
			"atan(0x{b=16,w=8,p=0}) = 0x{b=16,w=8,p=0}, should be 0x{b=16,w=8,p=0}",
			x, a1u, y)
	;;
}

const atan02 = {c
	var inputs : (uint64, uint64)[:] = [
		(0x10ba5f16340a0bc9, 0x10ba5f16340a0bc9),
		(0xd98ac92afca0e53d, 0xbff921fb54442d18),
		(0xec7a77dca00c3b26, 0xbff921fb54442d18),
		(0xee57f77337f8e709, 0xbff921fb54442d18),
		(0x9e25782df360cddd, 0x9e25782df360cddd),
		(0x9243219f73e1f319, 0x9243219f73e1f319),
		(0xa4d1ffde70716ab8, 0xa4d1ffde70716ab8),
		(0x48bcc07018965976, 0x3ff921fb54442d18),
		(0x1f864ca16540f910, 0x1f864ca16540f910),
		(0x15cb61e0de4d0245, 0x15cb61e0de4d0245),
		(0xd9bd7e5a3d6bc814, 0xbff921fb54442d18),
		(0x75cd7563af1d13f2, 0x3ff921fb54442d18),
		(0xed91a27ee1cf7fd4, 0xbff921fb54442d18),
		(0xc41d55b172ee68ee, 0xbff921fb54442d18),
		(0x558fe35fd3a69e4b, 0x3ff921fb54442d18),
		(0xa3cfec3df7c1c356, 0xa3cfec3df7c1c356),
		(0x38de5d01bc664ea9, 0x38de5d01bc664ea9),
		(0x190e8e5960b38edb, 0x190e8e5960b38edb),
		(0x03bd0fd0a2cdf14e, 0x03bd0fd0a2cdf14e),
		(0xb24e849d7122766b, 0xb24e849d7122766b),
		(0xda4ee410df592fdd, 0xbff921fb54442d18),
		(0xc76fb300ce286b3f, 0xbff921fb54442d18),
		(0x9f3dc5e92e95d81b, 0x9f3dc5e92e95d81b),
		(0x22ebeafb26c4e1cd, 0x22ebeafb26c4e1cd),
		(0x85af77b27a6c9ebd, 0x85af77b27a6c9ebd),
		(0x060bdb1f2d9809c8, 0x060bdb1f2d9809c8),
		(0xeaefd066fb169d3e, 0xbff921fb54442d18),
		(0x55036c3913a92f51, 0x3ff921fb54442d18),
		(0x5049f3035f2e17b9, 0x3ff921fb54442d18),
		(0xa6032d5682f84540, 0xa6032d5682f84540),
		(0xf33fb18d1d5b162a, 0xbff921fb54442d18),
		(0x9c88441ff7f72238, 0x9c88441ff7f72238),
		(0xbbd17263c0f5c1dc, 0xbbd17263c0f5c1dc),
		(0x4d82ee8ecba53872, 0x3ff921fb54442d18),
		(0x32f4e9594348833e, 0x32f4e9594348833e),
		(0xdc5ca2769af7825f, 0xbff921fb54442d18),
		(0xcfcc1defc79fc30b, 0xbff921fb54442d18),
		(0xcf7ce4fad9366c04, 0xbff921fb54442d18),
		(0x2919d12d8e3ce4ea, 0x2919d12d8e3ce4ea),
		(0x43914f32a6c79113, 0x3ff921fb54442d18),
		(0x3dc0726cc985fcb4, 0x3dc0726cc985fcb4),
		(0x39279f3510ab6c1c, 0x39279f3510ab6c1c),
		(0x888f53f3ef5a64eb, 0x888f53f3ef5a64eb),
		(0xf6698a51e74bc635, 0xbff921fb54442d18),
	][:]

	for (x, y) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var yf : flt64 = std.flt64frombits(y)
		var a1f : flt64 = math.atan(xf)
		var a2f : flt64 = math.atan2(xf, 1.0)
		var a1u : uint64 = std.flt64bits(a1f)
		var a2u : uint64 = std.flt64bits(a2f)
		testr.check(c, same64(a1u, a2u),
			"atan(0x{b=16,w=16,p=0}) = 0x{b=16,w=16,p=0}, but atan2(0x{b=16,w=16,p=0}, 1.0) = 0x{b=16,w=16,p=0}",
			x, a1u, x, a2u)

		testr.check(c, same64(a1u, y),
			"atan(0x{b=16,w=16,p=0}) = 0x{b=16,w=16,p=0}, should be 0x{b=16,w=16,p=0}",
			x, a1u, y)
	;;
}

const atan03 = {c
	var inputs : (uint32, uint32, uint32)[:] = [
		(0x00000000, 0x80000000, 0x40490fdb), /* atan2(+0, -0) = +Pi */
		(0x80000000, 0x80000000, 0xc0490fdb), /* atan2(-0, -0) = -Pi */
		(0x00000000, 0x00000000, 0x00000000), /* atan2(+0, +0) = +0 */
		(0x80000000, 0x00000000, 0x80000000), /* atan2(-0, +0) = -0 */
		(0x00000000, 0xc5a33ab8, 0x40490fdb), /* atan2(+0, x < 0) = +Pi */
		(0x00000000, 0x80000002, 0x40490fdb),
		(0x00000000, 0xdddddddd, 0x40490fdb),
		(0x80000000, 0xc5a33ab8, 0xc0490fdb), /* atan2(-0, x < 0) = -Pi */
		(0x80000000, 0x80000002, 0xc0490fdb),
		(0x80000000, 0xdddddddd, 0xc0490fdb),
		(0x00000000, 0x35a33ab8, 0x00000000), /* atan2(+0, x > 0) = +0 */
		(0x00000000, 0x00000002, 0x00000000),
		(0x00000000, 0x4ddddddd, 0x00000000),
		(0x80000000, 0x35a33ab8, 0x80000000), /* atan2(-0, x > 0) = -0 */
		(0x80000000, 0x00000002, 0x80000000),
		(0x80000000, 0x4ddddddd, 0x80000000),
		(0xdddddddd, 0x00000000, 0xbfc90fdb), /* atan2(y < 0, 0) = -Pi/2 */
		(0xc5a33ab8, 0x00000000, 0xbfc90fdb),
		(0x80000002, 0x00000000, 0xbfc90fdb),
		(0x4ddddddd, 0x00000000, 0x3fc90fdb), /* atan2(y > 0, 0) = +Pi/2 */
		(0x35a33ab8, 0x00000000, 0x3fc90fdb),
		(0x00000002, 0x00000000, 0x3fc90fdb),
		(0x7f800000, 0xff800000, 0x4016cbe4), /* atan2(+Inf, -Inf) = +3*Pi/4 */
		(0xff800000, 0xff800000, 0xc016cbe4), /* atan2(-Inf, -Inf) = -3*Pi/4 */
		(0x7f800000, 0x7f800000, 0x3f490fdb), /* atan2(+Inf, +Inf) = +Pi/4 */
		(0xff800000, 0x7f800000, 0xbf490fdb), /* atan2(-Inf, +Inf) = -Pi/4 */
		(0x7f800000, 0x4ddddddd, 0x3fc90fdb), /* atan2(+Inf, finite) = +Pi/2 */
		(0x7f800000, 0x00000001, 0x3fc90fdb),
		(0x7f800000, 0x80000004, 0x3fc90fdb),
		(0x7f800000, 0xfedcba87, 0x3fc90fdb),
		(0xff800000, 0x4ddddddd, 0xbfc90fdb), /* atan2(-Inf, finite) = -Pi/2 */
		(0xff800000, 0x00000001, 0xbfc90fdb),
		(0xff800000, 0x80000004, 0xbfc90fdb),
		(0xff800000, 0xfedcba87, 0xbfc90fdb),
		(0x6a520b4c, 0xff800000, 0x40490fdb), /* atan2(finite > 0, -Inf) = +Pi */
		(0x35a33ab8, 0xff800000, 0x40490fdb),
		(0x55a33ab8, 0xff800000, 0x40490fdb),
		(0xea520b4c, 0xff800000, 0xc0490fdb), /* atan2(finite < 0, -Inf) = -Pi */
		(0x95a33ab8, 0xff800000, 0xc0490fdb),
		(0xc5a33ab8, 0xff800000, 0xc0490fdb),
		(0x6a520b4c, 0x7f800000, 0x00000000), /* atan2(finite > 0, +Inf) = +0 */
		(0x35a33ab8, 0x7f800000, 0x00000000),
		(0x55a33ab8, 0x7f800000, 0x00000000),
		(0xea520b4c, 0x7f800000, 0x80000000), /* atan2(finite < 0, +Inf) = -0 */
		(0x95a33ab8, 0x7f800000, 0x80000000),
		(0xc5a33ab8, 0x7f800000, 0x80000000),
		(0x1aae129e, 0xde263fa8, 0x40490fdb), /* misc */
		(0xb76e98b6, 0xdbeb6637, 0xc0490fdb),
		(0x7112fd5b, 0x7509b252, 0x3b88a34d),
		(0xe53215fe, 0xcd0f08fc, 0xbfc90fdb),
		(0xcd47c963, 0x85268f36, 0xbfc90fdb),
		(0xfacd1adc, 0x79fd5d79, 0xbfa2b8c8),
		(0xfa3f79f2, 0xf5f06269, 0xbfc96033),
		(0xddc7b749, 0x5f3d9db0, 0xbe060c09),
		(0x63c8ee47, 0x792ac38f, 0x2a169cbe),
		(0xe3c24a4f, 0xe0f9b02f, 0xbfcba1c1),
		(0xe1f9385d, 0xe317764d, 0xc03c145d)
	][:]

	for (y, x, z_exp) : inputs
		var xf : flt32 = std.flt32frombits(x)
		var yf : flt32 = std.flt32frombits(y)
		var zf_act : flt32 = math.atan2(yf, xf)
		var z_act : uint32 = std.flt32bits(zf_act)

		testr.check(c, same32(z_act, z_exp),
			"atan(0x{b=16,w=8,p=0}, 0x{b=16,w=8,p=0}) = 0x{b=16,w=8,p=0}, should be 0x{b=16,w=8,p=0}",
			y, x, z_act, z_exp)
	;;
}

const atan04 = {c
	var inputs : (uint64, uint64, uint64)[:] = [
		(0x0000000000000000, 0x8000000000000000, 0x400921fb54442d18), /* atan2(+0, -0) = +Pi */
		(0x8000000000000000, 0x8000000000000000, 0xc00921fb54442d18), /* atan2(-0, -0) = -Pi */
		(0x0000000000000000, 0x0000000000000000, 0x0000000000000000), /* atan2(+0, +0) = +0 */
		(0x8000000000000000, 0x0000000000000000, 0x8000000000000000), /* atan2(-0, +0) = -0 */
		(0x0000000000000000, 0xc678962c36789c22, 0x400921fb54442d18), /* atan2(+0, x < 0) = +Pi */
		(0x0000000000000000, 0x8000000200000000, 0x400921fb54442d18),
		(0x0000000000000000, 0xdddddddddddddddd, 0x400921fb54442d18),
		(0x8000000000000000, 0xc678962c36789c22, 0xc00921fb54442d18), /* atan2(-0, x < 0) = -Pi */
		(0x8000000000000000, 0x8000000200000000, 0xc00921fb54442d18),
		(0x8000000000000000, 0xdddddddddddddddd, 0xc00921fb54442d18),
		(0x0000000000000000, 0x36789ac6987e678a, 0x0000000000000000), /* atan2(+0, x > 0) = +0 */
		(0x0000000000000000, 0x0000000000000002, 0x0000000000000000),
		(0x0000000000000000, 0x4ddddddd00000000, 0x0000000000000000),
		(0x8000000000000000, 0x36789ac6987e678a, 0x8000000000000000), /* atan2(-0, x > 0) = -0 */
		(0x8000000000000000, 0x0000000000000002, 0x8000000000000000),
		(0x8000000000000000, 0x4ddddddddddddddd, 0x8000000000000000),
		(0xdddddddddddddddd, 0x0000000000000000, 0xbff921fb54442d18), /* atan2(y < 0, 0) = -Pi/2 */
		(0xc678962c36789c22, 0x0000000000000000, 0xbff921fb54442d18),
		(0x8000000000000002, 0x0000000000000000, 0xbff921fb54442d18),
		(0x4ddddddddddddddd, 0x0000000000000000, 0x3ff921fb54442d18), /* atan2(y > 0, 0) = +Pi/2 */
		(0x36789ac6987e678a, 0x0000000000000000, 0x3ff921fb54442d18),
		(0x0000000000000002, 0x0000000000000000, 0x3ff921fb54442d18),
		(0x7ff0000000000000, 0xfff0000000000000, 0x4002d97c7f3321d2), /* atan2(+Inf, -Inf) = +3*Pi/4 */
		(0xfff0000000000000, 0xfff0000000000000, 0xc002d97c7f3321d2), /* atan2(-Inf, -Inf) = -3*Pi/4 */
		(0x7ff0000000000000, 0x7ff0000000000000, 0x3fe921fb54442d18), /* atan2(+Inf, +Inf) = +Pi/4 */
		(0xfff0000000000000, 0x7ff0000000000000, 0xbfe921fb54442d18), /* atan2(-Inf, +Inf) = -Pi/4 */
		(0x7ff0000000000000, 0x4ddddddddddddddd, 0x3ff921fb54442d18), /* atan2(+Inf, finite) = +Pi/2 */
		(0x7ff0000000000000, 0x0000000000000001, 0x3ff921fb54442d18),
		(0x7ff0000000000000, 0x8000000000000004, 0x3ff921fb54442d18),
		(0x7ff0000000000000, 0xf6789ac6987e678a, 0x3ff921fb54442d18),
		(0xfff0000000000000, 0x4ddddddddddddddd, 0xbff921fb54442d18), /* atan2(-Inf, finite) = -Pi/2 */
		(0xfff0000000000000, 0x0000000000000001, 0xbff921fb54442d18),
		(0xfff0000000000000, 0x8000000000000004, 0xbff921fb54442d18),
		(0xfff0000000000000, 0xf6789ac6987e678a, 0xbff921fb54442d18),
		(0x6a53a787aa520b4c, 0xfff0000000000000, 0x400921fb54442d18), /* atan2(finite > 0, -Inf) = +Pi */
		(0x3553a787aaa33ab8, 0xfff0000000000000, 0x400921fb54442d18),
		(0x5553a787aaa33ab8, 0xfff0000000000000, 0x400921fb54442d18),
		(0xea53a787aa520b4c, 0xfff0000000000000, 0xc00921fb54442d18), /* atan2(finite < 0, -Inf) = -Pi */
		(0x9553a787aaa33ab8, 0xfff0000000000000, 0xc00921fb54442d18),
		(0xc553a787aaa33ab8, 0xfff0000000000000, 0xc00921fb54442d18),
		(0x6a53a787aa520b4c, 0x7ff0000000000000, 0x0000000000000000), /* atan2(finite > 0, +Inf) = +0 */
		(0x3553a787aaa33ab8, 0x7ff0000000000000, 0x0000000000000000),
		(0x5553a787aaa33ab8, 0x7ff0000000000000, 0x0000000000000000),
		(0xea53a787aa520b4c, 0x7ff0000000000000, 0x8000000000000000), /* atan2(finite < 0, +Inf) = -0 */
		(0x9553a787aaa33ab8, 0x7ff0000000000000, 0x8000000000000000),
		(0xc553a787aaa33ab8, 0x7ff0000000000000, 0x8000000000000000),
		(0xc3a19e952471b77e, 0x3787d6fbb86b73be, 0xbff921fb54442d18), /* misc */
		(0x27aa78e1d1f0495c, 0xddd13f5bd464f1a5, 0x400921fb54442d18),
		(0xb8402fae1dfc652c, 0xba6fcc2cc1ed7e10, 0xc00921fb54432877),
		(0x66dce7f72e6044ad, 0x275302c43652a638, 0x3ff921fb54442d18),
		(0x4e4b96b837a90109, 0x0f6e0a35d7a1c7ae, 0x3ff921fb54442d18),
		(0x39e3f59d2cdaf453, 0xc1c9eec772632c8b, 0x400921fb54442d18),
		(0x0e80d207f7fc1dee, 0xdc3ccf9de59c1620, 0x400921fb54442d18),
		(0xc53a12760a738704, 0x013d7cd6b38fd663, 0xbff921fb54442d18),
		(0x24c9826368e2bab6, 0x673ee065b77f3411, 0x000000000000069c),
		(0x8648f8f528372eef, 0x70bdc29525e17f3d, 0x8000000000000000),
		(0x949d1ddd9d2c70d9, 0xed7a82c886f9b2b5, 0xc00921fb54442d18),
		(0x953f916c39b9967c, 0x0e43ed486cdf330c, 0xbff921fb54442d18),
		(0x9e3633326b5d0ef3, 0xf5c8913f8e308a65, 0xc00921fb54442d18),
		(0xaf1c2b5cfb3e9c97, 0xae2582384f4c4364, 0xbff92213c33fcf98),
		(0x13a48905d9e021e7, 0x764d46c054f3e5f8, 000000000000000000),
		(0x1c8142b5bce1d2a8, 0xe7f6c7dc0f16862c, 0x400921fb54442d18),
		(0xfb0f7a74951ff0d7, 0x0bb323507b3cbacf, 0xbff921fb54442d18),
		(0x4eac767a5766fcd1, 0xf8b2a6b240350c57, 0x400921fb54442d18),
		(0x2fb71a162e3ea604, 0x60d683328bfc7d57, 0x0ed06b3d4cc87ec9),
		(0xc5e748de4fffadde, 0x10ba5f16340a0bc9, 0xbff921fb54442d18),
		(0xd98ac92afca0e53d, 0xec7a77dca00c3b26, 0xc00921fb54442d18),
		(0x9243219f73e1f319, 0xa4d1ffde70716ab8, 0xc00921fb54442d18),
		(0x48bcc07018965976, 0x1f864ca16540f910, 0x3ff921fb54442d18),
		(0x15cb61e0de4d0245, 0xd9bd7e5a3d6bc814, 0x400921fb54442d18),
		(0xc41d55b172ee68ee, 0x558fe35fd3a69e4b, 0xae7d7006d1d45ebc),
		(0xa3cfec3df7c1c356, 0x38de5d01bc664ea9, 0xaae0d260b47f817c),
		(0xbee29ab450ee989f, 0x190e8e5960b38edb, 0xbff921fb54442d18),
		(0x03bd0fd0a2cdf14e, 0xb24e849d7122766b, 0x400921fb54442d18),
		(0x9f3dc5e92e95d81b, 0x22ebeafb26c4e1cd, 0xbc41102fc5241049),
		(0x85af77b27a6c9ebd, 0x060bdb1f2d9809c8, 0xbf921294a138c466),
		(0xeaefd066fb169d3e, 0x55036c3913a92f51, 0xbff921fb54442d18),
		(0xbbd17263c0f5c1dc, 0x4d82ee8ecba53872, 0xae3d7d699b3da6ce),
		(0xbef4c6bbd5b013f7, 0x32f4e9594348833e, 0xbff921fb54442d18),
		(0xcf7ce4fad9366c04, 0x2919d12d8e3ce4ea, 0xbff921fb54442d18),
		(0x3ff0de4d0245d9bd, 0x3ff07e5a3d6bc814, 0x3fe97e0262debf5b),
		(0x3ff0060bdb1f2d98, 0x3ff009c8eaefd066, 0x3fe91e401d092a68),
		(0x3ff04348833edc5c, 0x3ff0a2769af7825f, 0x3fe8c566f4d252eb),
		(0x3ff0d9366c042919, 0x3ff0d12d8e3ce4ea, 0x3fe9299e6eb7eb7f),
	][:]

	for (y, x, z_exp) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var yf : flt64 = std.flt64frombits(y)
		var zf_act : flt64 = math.atan2(yf, xf)
		var z_act : uint64 = std.flt64bits(zf_act)

		testr.check(c, same64(z_act, z_exp),
			"atan(0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}) = 0x{b=16,w=16,p=0}, should be 0x{b=16,w=16,p=0}",
			y, x, z_act, z_exp)
	;;
}

const atan05 = {c
	var inputs : (uint64, uint64, uint64)[:] = [
		(0xbee29ab450ee989f, 0xbee29ab450ec8003, 0xbee29ab450ec8002),
		(0xbef4c6bbd5b013f7, 0xbef4c6bbd5a46691, 0xbef4c6bbd5a46692),
	][:]

	for (x, y_perfect, y_acceptable) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var yf : flt64 = math.atan(xf)
		var yu : uint64 = std.flt64bits(yf)

		if !same64(yu, y_perfect) && !same64(yu, y_acceptable)
			testr.fail(c, 
			"atan(0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, wil also accept 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			x, y_perfect, y_acceptable, yu)
		;;
	;;
}

const atan06 = {c
	var inputs : (uint64, uint64, uint64, uint64)[:] = [
		(0x7ee54b8760669171, 0xb2be78b5d28bd697, 0x3ff921fb54442d18, 0x3ff921fb54442d19),
		(0x6ac1e65e358fa249, 0xbd59edfa1607e504, 0x3ff921fb54442d18, 0x3ff921fb54442d19),
		(0xd525a7f2ced4927f, 0x95ede4db7783fcc9, 0xbff921fb54442d18, 0xbff921fb54442d19),
		(0xccd3a5e34176f426, 0xa8a777c89a5ef6f2, 0xbff921fb54442d18, 0xbff921fb54442d19),
		(0x3ff075cd7563af1d, 0x3ff013f2ed91a27e, 0x3fe9823675699a92, 0x3fe9823675699a93),
		(0x3ff0f7c1c35638de, 0x3ff05d01bc664ea9, 0x3fe9b68915c8bb31, 0x3fe9b68915c8bb32),
		(0x3ff0bef4c6bbd5b0, 0x3ff013f732f4e959, 0x3fe9c8a841c1c952, 0x3fe9c8a841c1c953),
		(0x3ff0888f53f3ef5a, 0x3ff064ebf6698a51, 0x3fe9449d9c8c9bc0, 0x3fe9449d9c8c9bc1),
	][:]

	for (y, x, z_perfect, z_acceptable) : inputs
		var yf : flt64 = std.flt64frombits(y)
		var xf : flt64 = std.flt64frombits(x)
		var zf : flt64 = math.atan2(yf, xf)
		var zu : uint64 = std.flt64bits(zf)

		if !same64(zu, z_perfect) && !same64(zu, z_acceptable)
			testr.fail(c, 
			"atan2(0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, wil also accept 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			y, x, z_perfect, z_acceptable, zu)
		;;
	;;
}

const atan07 = {c
	var inputs : (uint64, uint64, uint64)[:] = [
		(0x18426dc1da370147, 0x988212e3418dac39, 0x40089fa4e7718127), /* start at j = 16 */
		(0x75f53f43ddf1bea3, 0xf5b664a94607233a, 0x3ffa2f66b9da6113),
		(0xa70f3b26830c1a94, 0xa74c60b2a9f15203, 0xc0089555472fa904),
		(0x3937099c00388aaa, 0x38faf7f608176196, 0x3ff7f6d4e7911d74),
		(0xea2807836bcaf607, 0x69edc29120f8d3db, 0xbff7e58f64ee105c),
		(0x8b4d90a9fe6bae02, 0x0b869a0bac14cf06, 0xbfb4e20b353d1cd2),
		(0xb4b65db1cbab83cf, 0xb4efd7158af2665a, 0xc0086e9d9bb6e77d),
		(0x4716d543d404ae35, 0xc7502d88541a937a, 0x40086dcab757f45c),
		(0xd821ab3bf346da52, 0xd857a58e9faf7b83, 0xc00863404ebd1155),
		(0x222a54c254087afe, 0xa260db8f64f01324, 0x40085aae7d9e5ede),
		(0xbf77a88b96eed0c5, 0x3fad49845988038f, 0xbfb9c332e78b9982),
		(0x4230048eaf9862bc, 0x41fb16739ee88b27, 0x3ff772a95cc1b5d0),
		(0x1100f13181258d69, 0x10cd58b7c1ae82ff, 0x3ff76844d0627ee0),
		(0x7b5c5a93ccb53cd6, 0xfb2a02a3c95263b7, 0x3ffaf59f0e4eb2a5),
		(0xb247b96c86d56ece, 0x3279bb34f20c78d6, 0xbfbd5fded650f614),
		(0x115f263dc39ac9a5, 0x112df4339ae6bb12, 0x3ff737fb844962b8),
		(0x0868e008bbd86562, 0x0838b0561328de61, 0x3ff728666e0adb09),
		(0xd4bb121d74efe2da, 0xd4ea966130621e4c, 0xc0081eb8c1a4153a),
		(0x88e5d8329155d426, 0x88b7242e0fc48972, 0xbffb3d3d48336602),
		(0x0d0ea0219a2c652d, 0x0d3c060e7f8db79d, 0x3fc160c1988f88aa),
		(0xc643f7c8910fb2aa, 0x46163c97e80a13ef, 0xbff6eb72b043c981),
		(0xf6e835bc9adeaf59, 0x76bc0ffdf6576c1d, 0xbff6d49ba0ac648b),
		(0x8c6daee970ffa651, 0x0c9945452e078530, 0xbfc2a918953f600a),
		(0xda75a3bf208dd25a, 0xdaa1ce8481388f38, 0xc007ed3cd8698716),
		(0x256084badab69b6f, 0xa58a3e76a1a9ac0f, 0x4007e25710289717),
		(0x192bbb1d943d1c72, 0x99558053a5ca0554, 0x4007daa06a0fe77a),
		(0x5ac36b61305c29f0, 0x5a9937845b781436, 0x3ff68ee124470819),
		(0x5c68b6c9ddb3ba95, 0xdc92798f09125a3b, 0x4007ceaaaa488a83),
		(0x6391aa182e1d70d9, 0xe3b9d8cda07245bf, 0x4007c76a07bf2989),
		(0xbc68b545ae310bd6, 0x3c41338754f714d5, 0xbff66029d8a55e48),
		(0x7d5059dea1719a3a, 0x7d2786542fd88ffd, 0x3ff64924d073ac1c),
		(0x53aab9beef29438b, 0x5383baac71cff20e, 0x3ff63676298edf36),
		(0x30822d2315e384fa, 0xb0a8494f9e7c25f1, 0x4007a72c29d2ead8),
		(0x5d88506b28721aeb, 0x5daff0d1a8860f63, 0x3fc8124991d9ed52),
		(0x848effeaebeb397a, 0x04b3e7d641cd15d5, 0xbfc89c0bddbcf109),
		(0xab474e4dc88b6320, 0xab6d3e4cb75879b9, 0xc0078f3604696ffb),
		(0x5afc797a50fff365, 0xdb219c67f404cafd, 0x40078990f8464cb6),
		(0x4e6bed9552b442f7, 0xce90cbb1e8f96d77, 0x40077e47244135f4),
		(0xd23f67b8daeaa1cd, 0x521a57dcda8bd0b1, 0xbff5d34d1830378e),
		(0x200f3502581f0c00, 0x1feadb65c0d29de5, 0x3ff5bdf3d5eeee34),
		(0x2819e6a5a099f07c, 0xa7f6987e601acbee, 0x3ffc918895432ab5),
		(0x6a06f6146c77eb36, 0xea29db6e2e2b221b, 0x400762945f726fc0),
		(0x3df11cfec787e47d, 0x3dcf1da836e547fb, 0x3ff58e991eb48d58),
		(0xd98eb9a768d3b13c, 0x596c4b654760f131, 0xbff58324124d2f0c),
		(0x83ea73b5e71eb08d, 0x03c8cb5bb22e1b8c, 0xbff57329b63cf62d),
		(0x5bf364f87b9850a1, 0x5c14713fe742a7b1, 0x3fcdcf07dd413790),
		(0x4329fd6f8a5c9c09, 0xc34afddcf85aa8f3, 0x40073e2fdb6f0d04),
		(0xc459a529603faebe, 0xc47a0903b2bab70a, 0xc007337dbdbc972c),
		(0xf155d5bc8bbbc622, 0xf175fa349aeb35d6, 0xc0072f63e3e01cd1),
		(0xc2ff7df0c28d2d98, 0x431f3588db6a0ce4, 0xbfcfa14c1091d92a),
		(0xcb98fb0c1faefad6, 0x4b79ba56a9a81681, 0xbff519c591857427),
		(0xc1f6eaccd468f9dc, 0xc215ed95c0b8dd82, 0xc007169655bd9847),
		(0xcfaf375aaa174fd7, 0x4f90a24cd877f957, 0xbff4f773f34d6a52),
		(0x5d404fa9511420bd, 0xdd5e26d9482f9752, 0x400704f98a04df78),
		(0xc83d634df8159064, 0x481fecb010d984d8, 0xbff4e3cac9a2565f),
		(0xf2acd33690651c1d, 0xf2c9dcbcd74009c7, 0xc006f571800acf60),
		(0xa6d1c7979c5718c5, 0x26efa12e7273ea28, 0xbfd189143428723d),
		(0xf0aca04752feb2b3, 0xf0903cbb018d78c1, 0xbffd8deb869dad07),
		(0x13e6221db9bd1161, 0x940339a43410d0fc, 0x4006e40bcc4251a9),
		(0xf1449d321262f59a, 0xf1282a47a2951a26, 0xbffdb1af654de151),
		(0x8da10731ac7ff6c4, 0x8dbc847feeba9f63, 0xc006cfcb9724a57d),
		(0x993a3fc8bc79deb7, 0x991f96b86734466b, 0xbffdcf002904b697),
		(0x850ae8ca929d38cf, 0x85260ddf20107de1, 0xc006c3a0c653534f),
		(0x550d39c0ed02033b, 0x5527bb5ae216a837, 0x3fd31d4ff5141bb4),
		(0x69f04200fd15c44d, 0x6a09f5bbe0965894, 0x3fd36beb7ba30050),
		(0xea5103cbcd2dc0f8, 0xea6addccedc4cad9, 0xc006aded9c63e371),
		(0x66354277caa622f2, 0x661b2ecf586161fd, 0x3ff42eba1f1329a2),
		(0x827944bfe027fc91, 0x029395925de79e23, 0xbfd3f8386b70acdc),
		(0xc8578c33abd012b6, 0xc871f1ed754c80bb, 0xc00698c9033d2443),
		(0x36c47150cf44174b, 0x36ded6df6fba558b, 0x3fd47b977c18f044),
		(0x0392076753c5ad4d, 0x83aab570a430e601, 0x400687593a62215e),
		(0xab409115af3336d0, 0x2b5877b08ee26b9a, 0xbfd4e44b158c63c8),
		(0x025b46e2bba8aac6, 0x8273c70ac00f43f5, 0x400679fae4615e8f),
		(0xcb83e4d6f4a0f930, 0x4b6bbbc7e601ddbc, 0xbff3c45f6ead2fc0),
		(0x894070ba821a311d, 0x89576e66d85dfa8c, 0xc0066ef9792f16ef),
		(0xbe34ef324e717dd4, 0x3e1de4d09ab52519, 0xbff3a57e9fb9e4d6),
		(0xe18d9f521cb0e0bb, 0x61a49ca578fb4cd3, 0xbfd6133cf03299ed),
		(0x980a8c64968d03c9, 0x98225772e9299381, 0xc0065ae999121db5),
		(0x0a243a4c4e15733c, 0x8a0dbbfcdb7f1ba0, 0x3ffec47d07799e8b),
		(0x30ebfe62d6baac2f, 0xb0d4c33a3d8aecac, 0x3ffed090244929ea),
		(0x1ad0d3f4d1963ae1, 0x9ab93fd035e118a7, 0x3ffedfe5dfb819a7),
		(0xf4c7b73c55323728, 0x74df33d218f0a341, 0xbfd73e3dd0e9d6b4),
		(0x7fc7730f17b94425, 0x7fb1e36aa5f19e93, 0x3ff34d70518b2f0a),
		(0xa45ae4c0b2526558, 0xa471685078380a57, 0xc0062f1ece927028),
		(0x49031632c2e74c77, 0xc91858d8e8b972cf, 0x400624eb07ef7e19),
		(0xc9fa2a90bbdf54fd, 0x49e49a101827560d, 0xbff321d2ed9c9bf2),
		(0xcd3430e4ecbc9273, 0xcd49508246135777, 0xc00618d195a84255),
		(0x593e0312105fe577, 0x592821625d7288f0, 0x3ff3045358e522e4),
		(0x3c9d87375ce18bb9, 0x3c8804bcc678f476, 0x3ff2f3ceda086c71),
		(0xd2364efc21d22d8d, 0xd24b2fbffa709218, 0xc006049bacf46bfd),
		(0x455a71c01bcb719c, 0x456ff860d9a0d4a2, 0x3fd91915e32aa709),
		(0xae00c21ee6a731f5, 0xae13f99538b94618, 0xc005f48a43984d8d),
		(0x9ac24bc4af5dd567, 0x9aaef59c81be5029, 0xbfff8939b93cd223),
		(0xcc2151b4908db683, 0x4c0d79efa1932ddd, 0xbff2b23af38d32a8),
		(0x91f0443849a9df00, 0x11dbfefd41ae3d5d, 0xbff2a1a9f24970cc),
		(0xa5e237687877a0fb, 0x25f506dcba88a63b, 0xbfda2951404b2019),
		(0xdf7b27a4a6b4ee2e, 0xdf8f110382326777, 0xc005d625ecf371a1),
		(0xae86d7602355270b, 0xae7432cdebdccba1, 0xbfffcb2a540c5fed),
		(0x287d154fbdf9fc0f, 0xa869f56a3ef77a7e, 0x3fffd94f19c79d25),
		(0x0560e0d82db59047, 0x8572d5c422c9c0cf, 0x4005c34a330f2ea9),
		(0xf2d7467700a5f6f6, 0xf2e99ed266fb898d, 0xc005b8c77efcdd76),
		(0x7b7aab211d5ae862, 0x7b685e3df97eab47, 0x3ff246a054d4ca30),
		(0xbce01a15fc14603f, 0x3ccdbbf7cd56a322, 0xbff2366ffd36a688),
		(0x3aba009f287274a8, 0x3aa835a8c9b86f42, 0x3ff229654835b3f6),
		(0x74f69aa82ae6ae36, 0xf50804d5d9b96f4d, 0x40059d3ff942caf1),
		(0xf00bd0188ab5f549, 0xeffa4a0666680629, 0xc000192c055d2cea),
		(0xf966c40358ee231f, 0xf955a9e47ee17b2a, 0xc0001e80c754ecbf),
		(0xef0eb2afdf5e914e, 0x6efd83223ec05254, 0xbff1f6a77f563010),
		(0xeb402915a3acc0e7, 0xeb2f48bba99a1e8a, 0xc0002c17cb7296fe),
		(0xe7119821252f5168, 0xe7220ebe8d4ade9a, 0xc005818f17dd93fe),
		(0x2fe7b730d0019f73, 0xaff8153060f5e0eb, 0x400578f5a3c8b63d),
		(0x421abce463ace518, 0xc22af76910fd4298, 0x400573632910fd19),
		(0x1b8c7b64e857b17f, 0x9b7c720983ec6dcb, 0x4000457d58d0072a),
		(0x4ed09b917d422bba, 0x4ec0bde86f0d6e2a, 0x3ff1a9ab56acdc13),
		(0x1ac4929922665d01, 0x1ad4414eed995920, 0x3fde12d20b86172f),
		(0xd3c9c0a93edc039b, 0x53d926a1de6138a9, 0xbfde486e28ca8ef5),
		(0x998d665d7a57087a, 0x197e51760e709cfe, 0xbff184061e1f4dc9),
		(0x845b25117034a928, 0x046a2b75ea771ab1, 0xbfde9ec075594604),
		(0x4103349aefa22309, 0x40f41f2648539bbf, 0x3ff169784d6d111c),
		(0xbb6eacc18d908188, 0x3b7d1de075b5f774, 0xbfdf0756f298d7b0),
		(0x46d62b3c7dc84ee7, 0xc6c78930cb465f26, 0x4000786e39a79f00),
		(0xd4403bcec8aee8ab, 0x544e56b935d9fb5b, 0xbfdf71b509d061d7),
		(0x493307757157381f, 0xc9248bc78a541d30, 0x400086cbed68f834),
		(0x3491c69fff9a59bb, 0xb48346e8b2cfe7dd, 0x40008a8bb3c6676f),
		(0x04ec3f1f3d711c03, 0x84ded70b376da1ed, 0x4000905e0bb52c89),
		(0xfcdb52d3d18e3a40, 0xfce8bd40675bf7a6, 0xc00518a7beaf01e8),
		(0xe9065952a9652233, 0xe9142bf74757fcf9, 0xc00515eef025e8d7),
		(0x937fb429117409d8, 0x938c5e4f3ea26f39, 0xc0050e650830c708),
		(0xab95c177fc58320c, 0xaba3633be704d70e, 0xc0050ad48b6fc0ee),
		(0xc1fd1980fb96cdbb, 0x41f081d2b0e3346c, 0xbff0e072570bab0c),
		(0xfb3e1409a3aac153, 0x7b31299de4625efe, 0xbff0d620e73490c7),
		(0x362445d91f2158c6, 0xb6174ee311b98730, 0x4000bd7e82f648aa),
		(0xa973576024c5cffd, 0xa980ba86c0a0af2b, 0xc004f083ccd3f3e2),
		(0x6e5366b29436f556, 0x6e60ad029064c091, 0x3fe0dc16f81f34f9),
		(0x594f6a41578e84b4, 0x595ae034c59be57d, 0x3fe0ecccc9db1d49),
		(0x578d5e6f4974d6fd, 0x5798df248e1d8929, 0x3fe111196f271e7a),
		(0x537cb0e054b6923e, 0x5371029b86d81056, 0x3ff091f1a9dfd0c6),
		(0xe1e6318db224d875, 0x61da859400b913e9, 0xbff083edca6c0ecd),
		(0xdccc45f468c3e71c, 0xdcd77e2ee145872a, 0xc004cc956cd5a28e),
		(0x67c3a7faad55a8ee, 0xe7d03d98b1a75491, 0x4004c7752b4fdcd9),
		(0x2891970a3578028e, 0xa89ce872cfb4636f, 0x4004c27a3b67cdcf),
		(0x8197efb3f923b946, 0x81a3825edc1edafc, 0xc004bb0d616fd574),
		(0x0116a707885bea19, 0x01225827e6c86b5d, 0x3fe1b34228cc2534),
		(0xc8151285ea7320cf, 0xc820fc98709a4ee5, 0xc004b0f7200e8a99),
		(0xd73da3db3f61f8f1, 0x5747b5df8a698ef3, 0xbfe1e04ba329ad62),
		(0x9265b496538d7585, 0x125b44a6f29fa8b0, 0xbff028b7a225c296),
		(0xbd9516a13ead26dd, 0xbd8aaaaabfd125d9, 0xc00113a87fe993a5),
		(0xedc420889150a1ef, 0x6dcf9a6066e34016, 0xbfe2259bce59e2ef),
		(0x997d5b3eb41cba8d, 0x1972cccd840f3247, 0xbff004e5bad8a285),
		(0x5f28fe17a9282e60, 0x5f336ac7a90ee043, 0x3fe24c876b3ecc7e),
		(0xd3bf8d4067b1be95, 0x53c85bfb3f716245, 0xbfe26404b24839b8),
		(0x25b895214b2b60e6, 0x25b0062fa5260ec0, 0x3fefc7a4f0f7a7d9),
		(0xc530319eb1a1e2a5, 0xc538aaaf7c51c545, 0xc0047c3a760d1cd9),
		(0xeb98221ee7d54a2f, 0xeba24cbee2b4d677, 0xc004781bcc01a10f),
		(0xe2611e7acd950bd0, 0xe269bd3f709cf616, 0xc0046ffb487c0c68),
		(0xf257d9cfc126807e, 0x724fe41944255eca, 0xbfef685db0489536),
		(0x60a2c666176c460d, 0xe0abeccbd99ea353, 0x400465bbec65b35d),
		(0x4b9e86470c8af801, 0xcba6946dd1f68f93, 0x400460ae560b89ee),
		(0x6c00e2b8c8111aae, 0xec08d824cdc92e8b, 0x40045b7172d19dd8),
		(0x9d6d541b54057b72, 0x1d7572d679275923, 0xbfe330baa38d160f),
		(0x4ee3d469e11c3b1e, 0xceecd622cce943fb, 0x40045045ab0feb07),
		(0x8df338c143e7fe4a, 0x8dfbcefefbf7b3b7, 0xc0044b5717874d94),
		(0x2b3ce380a38fd495, 0xab44c4c877e2d851, 0x4004456e8c85e86c),
		(0x35b6254148b0cc48, 0x35aef51eba25a22d, 0x3feebea390775bfc),
		(0x0646804d41598e1c, 0x863f963de5cfd390, 0x4001765bc9bab45f),
		(0xf5adf458b64d8736, 0x75b52ec33d04e25f, 0xbfe3b1b56ae7344b),
		(0x7d60b41f76311796, 0xfd67815e15d963fd, 0x400430ad3c195d17),
		(0x3611a21dc610b785, 0xb618aa3b1b3b0f86, 0x40042adcc77995cf),
		(0x7021254ec8bc72f6, 0x7027e00c63e273e9, 0x3fe3edf444b73214),
		(0x7e63b7e103cd0489, 0xfe6b3f53fceb3bfa, 0x40041f0862b0af2d),
		(0x9d9ebb9f04cdf5d7, 0x1da52bc78ab56424, 0xbfe417560828f6d8),
		(0xda9cfabc3c20417a, 0xda95246166d15ad5, 0xc0019bd2040f1c7e),
		(0xf66766aa0d38e359, 0xf66fcec939e5a5bb, 0xc0040ef609989e8e),
		(0xd4045e5d16392197, 0xd40b9412c98c303b, 0xc0040b27876f70db),
		(0xc9b37a2a0a83c474, 0xc9ba326a8ba44628, 0xc00404a61a0681d2),
		(0x21022b885f2bcb4d, 0xa10852810f14a7d9, 0x4003fff572516d6e),
		(0xf5cac65697217a36, 0xf5d1df272cc38ccc, 0xc003fd4b443c03a2),
		(0xb055c66f4fc8c399, 0xb05ced1fe2377c16, 0xc003f8739e21830a),
		(0x71ad384d868e6b06, 0xf1a621cf2fe7d1dc, 0x4001c095f2a99696),
		(0x4d17c1de6ac68d6b, 0xcd1213396573b855, 0x4001c4fe437c1196),
		(0x9b0d3fb9cbf1b4c6, 0x1b0664d3b4eeb0d2, 0xbfed5b11c719fe27),
		(0x0fb3fe727a21e5ac, 0x8fba01df1f586bf8, 0x4003e3b20f8de5db),
		(0x3f21c2ca49b88075, 0xbf26f05cd43cab02, 0x4003dca664c31bed),
		(0x6cc6f1d079f04b98, 0xeccd8e177ab76b6e, 0x4003da024b7a6ca8),
		(0xb106c2d0afd0eaad, 0x310d28333e770e2d, 0xbfe535d434ff2257),
		(0xeb08335b08e8334f, 0xeb0ecd205b92dea2, 0xc003ce17cbb48a9e),
		(0x4250b2cc567b0093, 0x42552deaa34b7e5b, 0x3fe55d5a9c073f8a),
		(0x1e91017ab850072a, 0x9e8af50a0be3b825, 0x4001ed927090ff6e),
		(0x958b250c719e9fd7, 0x9585a086f26895d7, 0xc001f2c5bba0f280),
		(0x7f42ee1989c19aa5, 0xff47a9a405acd3d9, 0x4003bc1d6d17b2f4),
		(0xe0c9bf3add3dc69f, 0xe0c4b9d987749d38, 0xc001fd126d2f17ff),
		(0x77fd24e199b5c560, 0x7802080019b6ad88, 0x3fe5c00c41b089be),
		(0x1fb8dc0fd3ff8fca, 0x9fbea2df8431838b, 0x4003ade63a714362),
		(0x83edb83bbda9ff38, 0x83e841c15223cf20, 0xc0020aeae788d82b),
		(0x2f40b627343797bf, 0xaf3b72af6d17d8f0, 0x40021118e92733b6),
		(0x22ad7d192e8784cb, 0x22a84d2fe4f68aa1, 0x3fec3586c884069b),
		(0x4326ee8596b374ae, 0xc32bb17d8682f8f9, 0x4003998c58705302),
		(0xaee48c63ca918372, 0xaee115755ee72125, 0xc0021d7816852a75),
		(0x9c0bcb204ceabc61, 0x1c109f3e0a1b79d4, 0xbfe648603bcc455f),
		(0x479a3a8c8f6446ff, 0x479f43821aefc385, 0x3fe65661082eeea4),
		(0xd2b8fa499fed0f9f, 0xd2b50cd6798137ed, 0xc0022b274cd99e10),
		(0x6ad25250a41576bb, 0xead59e36376d5d94, 0x400382238981cc06),
		(0xb9219a8a8f7efe91, 0x3924ac87f8e6b194, 0xbfe6924cc8683709),
		(0x37beda024f45aedc, 0x37ba5f9abbc7859b, 0x3feba1be0e2fe373),
		(0x6fc8d5499dc46f95, 0xefccd7149f2bb89c, 0x40037218f702b002),
		(0x7ca3becda1d57a3f, 0xfca6e07559fa362b, 0x40036faf147e21fe),
		(0x9ef8de78ed7949ef, 0x9efca914a41f2409, 0xc0036a4d5a44860a),
		(0x88bc103761961766, 0x88b86ecd68ae0774, 0xc0024c137e9920a2),
		(0x5a04350fba24bc39, 0x5a071ac1f8f03b5c, 0x3fe6fecf73bc6287),
		(0xb0da7bac5589300e, 0xb0de18d46a4b846c, 0xc0035c1e7a96f4bc),
		(0xda8ca23fbc0a437e, 0xda8947fa661a2f3f, 0xc0025a4c5b426b40),
		(0x3d6061ffc7256d60, 0x3d627ef1b2a33874, 0x3fe7324a015abfea),
		(0x85aafe4c0caab70b, 0x85ae5951fb175351, 0xc0035131e1813858),
		(0x5b472dc1329a819b, 0xdb49f252edb042d8, 0x40034cc10f47cfd3),
		(0x5af048199a331d49, 0xdaf215c3b1ceecb8, 0x400344db170384a7),
		(0x6d3983381694e0fd, 0x6d3c4bed9dbefd56, 0x3fe77a83f0976226),
		(0x820385902a31f7d0, 0x82058f0517dfa1c0, 0xc0033ef3a4e28c4d),
		(0x6b19ea8931b5c441, 0x6b1c7b28c26fbbcf, 0x3fe79fffc4138dcb),
		(0x29e61553c19ddd07, 0x29e827f3d30d2850, 0x3fe7b301fac7e326),
		(0xfac0e54d45520a82, 0x7ac266978d40aba1, 0xbfe7c4e2fc5c5a43),
		(0xe058426c7875fb1e, 0xe05a4c0ce0f0e3c0, 0xc0032bfbb10cb569),
		(0x8d49ec500d90d579, 0x8d4805cc07d433de, 0xc0028b98c8b802ca),
		(0x0b15c458a6db43ce, 0x8b1762a8fd98d47a, 0x400322dcb52b5ef4),
		(0x486a31a4c0d3a267, 0xc86c0a2479e4bc7e, 0x40031f2867d112f7),
		(0x48917f21b9fcbe55, 0x489060b8296d7b50, 0x3fea3072865b102d),
		(0xd9c2672a452fdbd9, 0xd9c1524843cb3b6c, 0xc0029b8045923d1f),
		(0x9277a69bceb041df, 0x927657a5eb7794f3, 0xc0029f3d4968e8ec),
		(0x0984c57a7e9d51da, 0x8985e00a293f6a14, 0x40030e7acd40c442),
		(0xf0cb5b77a2c2f56a, 0xf0ccafe7a265b2f1, 0xc0030a129477250a),
		(0x02740ba4fb4cdb85, 0x8274ef33fe8f8762, 0x400305e720d195af),
		(0x9357aa6b6e40e4ce, 0x1356ba9fc9b8c04a, 0xbfe9c75ab7859d93),
		(0xc39eaa3101026fc5, 0x439fcb8dfd282364, 0xbfe88dbfbb9e3a03),
		(0xc06ef5bac1f0755a, 0xc06ff8851d5dfcf5, 0xc002fa61c91e15e9),
		(0x03a8d2f6619e1128, 0x03a988403eb55bcd, 0x3fe8aec91f700e10),
		(0x93cb2e10bb006567, 0x13cbcd7e9dcf755a, 0xbfe8c53297e66569),
		(0x90ce665b5f887a3c, 0x10cdcdabe52970fd, 0xbfe97322edfec555),
		(0x9252ad57a250df33, 0x1252fc2a219dff1c, 0xbfe8df02dad91818),
		(0xa4f9e11b6cb66d86, 0xa4f9947d89a8a498, 0xc002cd934ed639b9),
		(0x4eb98661a247fdce, 0xceb9babf2dbaa10b, 0x4002e1a8e0f0f5b7),
		(0x13758224e135e1c5, 0x937596e7d8816f9c, 0x4002dd5714deeb1e),
		(0x26ecf80bd6fb389b, 0xa6ecf11130353926, 0x4002d885ae886a69), /* j = 256 */
	][:]

	for (y, x, z_exp) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var yf : flt64 = std.flt64frombits(y)
		var zf_act : flt64 = math.atan2(yf, xf)
		var z_act : uint64 = std.flt64bits(zf_act)

		testr.check(c, same64(z_act, z_exp),
			"atan(0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}) = 0x{b=16,w=16,p=0}, should be 0x{b=16,w=16,p=0}",
			y, x, z_act, z_exp)
	;;
}

const atan08 = {c
	testr.check(c, std.isnan(math.atan(std.flt64nan())), "atan(NaN64) should be NaN")
	testr.check(c, std.isnan(math.atan(std.flt32nan())), "atan(NaN32) should be NaN")

	testr.check(c, std.isnan(math.atan2(std.flt64nan(), 3.0)), "atan2(NaN64, 3.0) should be NaN")
	testr.check(c, std.isnan(math.atan2(std.flt32nan(), -2.0)), "atan2(NaN32, -2.0) should be NaN")
	testr.check(c, std.isnan(math.atan2(6.0, std.flt64nan())), "atan2(6.0, NaN64) should be NaN")
	testr.check(c, std.isnan(math.atan2(4.0, std.flt32nan())), "atan2(4.0, NaN32) should be NaN")
}