We are currently in the process of converting the website to the new design. Some pages, like this one, are still broken. We appreciate your patience.
RISCY BUSINESS»Episode Guide
Fun with Fixed Point Math
?
?

Keyboard Navigation

Global Keys

[, < / ], > Jump to previous / next episode
W, K, P / S, J, N Jump to previous / next marker
t / T Toggle theatre / SUPERtheatre mode
V Revert filter to original state Y Select link (requires manual Ctrl-c)

Menu toggling

q Quotes r References f Filter y Link c Credits

In-Menu Movement

a
w
s
d
h j k l


Quotes and References Menus

Enter Jump to timecode

Quotes, References and Credits Menus

o Open URL (in new tab)

Filter Menu

x, Space Toggle category and focus next
X, ShiftSpace Toggle category and focus previous
v Invert topics / media as per focus

Filter and Link Menus

z Toggle filter / linking mode

Credits Menu

Enter Open URL (in new tab)
0:09Recap and set the stage for the day
0:09Recap and set the stage for the day
0:09Recap and set the stage for the day
1:03Don the thinking cap
1:03Don the thinking cap
1:03Don the thinking cap
1:38Working through the cycles-per-second formula for measure_cpu_freq()
🖌
1:38Working through the cycles-per-second formula for measure_cpu_freq()
🖌
1:38Working through the cycles-per-second formula for measure_cpu_freq()
🖌
16:12Check our formula with the one in measure_cpu_freq()
🖌
16:12Check our formula with the one in measure_cpu_freq()
🖌
16:12Check our formula with the one in measure_cpu_freq()
🖌
18:46Reverse engineer the cycles-per-second formula
🖌
18:46Reverse engineer the cycles-per-second formula
🖌
18:46Reverse engineer the cycles-per-second formula
🖌
20:22riskyfive They are basically doing fixed point math
🗪
20:22riskyfive They are basically doing fixed point math
🗪
20:22riskyfive They are basically doing fixed point math
🗪
21:02Computing the decimal portion of a real number in fixed point mathematics
🖌
21:02Computing the decimal portion of a real number in fixed point mathematics
🖌
21:02Computing the decimal portion of a real number in fixed point mathematics
🖌
21:58riskyfive Instead of doing float x = 3.14, you do int x = 314 and the point is implicit
🗪
21:58riskyfive Instead of doing float x = 3.14, you do int x = 314 and the point is implicit
🗪
21:58riskyfive Instead of doing float x = 3.14, you do int x = 314 and the point is implicit
🗪
23:22riskyfive Notice that in one part you have / and then you have another part that is nearly equal but uses %
🗪
23:22riskyfive Notice that in one part you have / and then you have another part that is nearly equal but uses %
🗪
23:22riskyfive Notice that in one part you have / and then you have another part that is nearly equal but uses %
🗪
25:37Determine to work through an example on the whiteboard
25:37Determine to work through an example on the whiteboard
25:37Determine to work through an example on the whiteboard
26:34riskyfive Use a spreadsheet or C program, to make it easier to compute other values
🗪
26:34riskyfive Use a spreadsheet or C program, to make it easier to compute other values
🗪
26:34riskyfive Use a spreadsheet or C program, to make it easier to compute other values
🗪
27:06Plug some example values into our cycles-per-second formula
🖌
27:06Plug some example values into our cycles-per-second formula
🖌
27:06Plug some example values into our cycles-per-second formula
🖌
41:04Summarise how this fixed point calculation works
🖌
41:04Summarise how this fixed point calculation works
🖌
41:04Summarise how this fixed point calculation works
🖌
42:47riskyfive I can explain it another way
🗪
42:47riskyfive I can explain it another way
🗪
42:47riskyfive I can explain it another way
🗪
43:49riskyfive Just forget everything after the + to start with
🗪
43:49riskyfive Just forget everything after the + to start with
🗪
43:49riskyfive Just forget everything after the + to start with
🗪
45:56riskyfive Say we have 200 cycles (delta_mcycle). We divide by the ticks (delta_mtime). So now we have number of cycles per tick. We multiply by the number of ticks per second (mtime_freq) so now we have cycles per second
🗪
45:56riskyfive Say we have 200 cycles (delta_mcycle). We divide by the ticks (delta_mtime). So now we have number of cycles per tick. We multiply by the number of ticks per second (mtime_freq) so now we have cycles per second
🗪
45:56riskyfive Say we have 200 cycles (delta_mcycle). We divide by the ticks (delta_mtime). So now we have number of cycles per tick. We multiply by the number of ticks per second (mtime_freq) so now we have cycles per second
🗪
47:57Pose the question: How does n % m / m give the decimal part of the number?
🖌
47:57Pose the question: How does n % m / m give the decimal part of the number?
🖌
47:57Pose the question: How does n % m / m give the decimal part of the number?
🖌
49:29riskyfive So 201 cycles / 10 ticks = floor(20.1) cycles per tick. We take the 20 and multiply by, say, 100 ticks per second so we have 2000 cycles per second
🗪
49:29riskyfive So 201 cycles / 10 ticks = floor(20.1) cycles per tick. We take the 20 and multiply by, say, 100 ticks per second so we have 2000 cycles per second
🗪
49:29riskyfive So 201 cycles / 10 ticks = floor(20.1) cycles per tick. We take the 20 and multiply by, say, 100 ticks per second so we have 2000 cycles per second
🗪
50:06riskyfive 201 % 10 = 1. Multiply by 100 and divide by 10 we get 2010 cycles per second, and we recover the part we lost in the division
🗪
50:06riskyfive 201 % 10 = 1. Multiply by 100 and divide by 10 we get 2010 cycles per second, and we recover the part we lost in the division
🗪
50:06riskyfive 201 % 10 = 1. Multiply by 100 and divide by 10 we get 2010 cycles per second, and we recover the part we lost in the division
🗪
50:22The relationship between a remainder and a decimal
🖌
50:22The relationship between a remainder and a decimal
🖌
50:22The relationship between a remainder and a decimal
🖌
53:56Read about reciprocal1
📖
53:56Read about reciprocal1
📖
53:56Read about reciprocal1
📖
56:31riskyfive delta_mtime is what determines what the conceptual decimal point is. Say delta_mtime = 100, if you do x % delta_mtime and get 33, then the 33 means you don't have a whole delta_mtime unit. But after you multiply it by something you might get >= 100, so when you divide by delta_mtime again you get >= 1
🗪
56:31riskyfive delta_mtime is what determines what the conceptual decimal point is. Say delta_mtime = 100, if you do x % delta_mtime and get 33, then the 33 means you don't have a whole delta_mtime unit. But after you multiply it by something you might get >= 100, so when you divide by delta_mtime again you get >= 1
🗪
56:31riskyfive delta_mtime is what determines what the conceptual decimal point is. Say delta_mtime = 100, if you do x % delta_mtime and get 33, then the 33 means you don't have a whole delta_mtime unit. But after you multiply it by something you might get >= 100, so when you divide by delta_mtime again you get >= 1
🗪
57:41Is it true that n % m / m = 1 / m % m
🖌
57:41Is it true that n % m / m = 1 / m % m
🖌
57:41Is it true that n % m / m = 1 / m % m
🖌
1:00:05riskyfive Think of delta_mtime as being a percentage. If you get 0.33 that's 33%. You will only get an integer again if you cross the 100% line
🗪
1:00:05riskyfive Think of delta_mtime as being a percentage. If you get 0.33 that's 33%. You will only get an integer again if you cross the 100% line
🗪
1:00:05riskyfive Think of delta_mtime as being a percentage. If you get 0.33 that's 33%. You will only get an integer again if you cross the 100% line
🗪
1:01:21Determine to sleep on this to fully understand it
1:01:21Determine to sleep on this to fully understand it
1:01:21Determine to sleep on this to fully understand it