問題 2.1
計算
Number | Calculation |
---|---|
1.0 | (−1)0×2127−127×1.0000…0 |
2.0 | (−1)0×2128−127×1.0000…0 |
3.0 | (−1)0×2128−127×1.1000…0 |
4.0 | (−1)0×2129−127×1.0000…0 |
5.0 | (−1)0×2129−127×1.0100…0 |
6.0 | (−1)0×2129−127×1.1000…0 |
7.0 | (−1)0×2129−127×1.1100…0 |
8.0 | (−1)0×2130−127×1.0000…0 |
9.0 | (−1)0×2130−127×1.0010…0 |
10.0 | (−1)0×2130−127×1.0100…0 |
確認
exercise_2_1.frag
#version 300 esprecision highp float;precision highp int;out vec4 fragColor;uniform float u_time;uniform vec2 u_resolution;void main(){vec2 pos = gl_FragCoord.xy / u_resolution.xy;pos *= vec2(32.0, 10.0);uint[10] a = uint[](floatBitsToUint(1.0),floatBitsToUint(2.0),floatBitsToUint(3.0),floatBitsToUint(4.0),floatBitsToUint(5.0),floatBitsToUint(6.0),floatBitsToUint(7.0),floatBitsToUint(8.0),floatBitsToUint(9.0),floatBitsToUint(10.0));if (fract(pos.x) < 0.1){if (floor(pos.x) == 1.0){fragColor = vec4(1, 0, 0, 1);} else if (floor(pos.x) == 9.0){fragColor = vec4(0, 1, 0, 1);} else {fragColor = vec4(0.5);}} else if (fract(pos.y) < 0.1){fragColor = vec4(0.5);} else {uint b = a[int(pos.y)];b = (b << uint(pos.x)) >> 31;fragColor = vec4(vec3(b), 1.0);}}