Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- int[512] tab;
- int mul (byte a, byte b)
- {
- ushort x = cast(ushort)(a + b)&511;
- ushort y = cast(ushort)(a - b)&511;
- return tab[x] - tab[y];
- }
- void main (string[] args)
- {
- int failed = 0;
- for (auto i = 0; i < 512; i++)
- {
- int a = i < 256 ? i : i - 512;
- tab[i] = a*a/4;
- }
- for (auto x = -128; x < 128; x++)
- {
- for (auto y = -128; y < 128; y++)
- {
- if (mul (cast (byte)x, cast (byte)y) != x*y)
- {
- writefln ("failed %s %s", x, y);
- failed++;
- goto end;
- }
- }
- }
- end:
- if (0 == failed) writeln ("passed!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement