Translation

(itstool) path: step/para
Append the digit to a buffer we will use later to produce the packed decimal we can send to the <acronym>FPU</acronym>.
149/1190
Context English Persian State
<userinput>00000000150</userinput> <userinput>00000000150</userinput>
Clearly, we need to strip those leading zeros.
So, we might consider reading the user input as is, converting it to binary inside the <acronym>FPU</acronym>, and printing it out from there.
But... اما...
What if the user types something like this: اگر کاربر چیزی شبیه به این بنویسد چه:
<userinput>17459765723452353453534535353530530534563507309676764423</userinput> <userinput>17459765723452353453534535353530530534563507309676764423</userinput>
Ha! The packed decimal <acronym>FPU</acronym> format lets us input 18–digit numbers. But the user has entered more than 18 digits. How do we handle that?
Well, we <emphasis>could</emphasis> modify our code to read the first 18 digits, enter it to the <acronym>FPU</acronym>, then read more, multiply what we already have on the <acronym>TOS</acronym> by 10 raised to the number of additional digits, then <function>add</function> to it.
Yes, we could do that. But in <emphasis>this</emphasis> program it would be ridiculous (in a different one it may be just the thing to do): Even the circumference of the Earth expressed in millimeters only takes 11 digits. Clearly, we cannot build a camera that large (not yet, anyway).
So, if the user enters such a huge number, he is either bored, or testing us, or trying to break into the system, or playing games—doing anything but designing a pinhole camera.
What will we do? چه خواهیم کرد؟
We will slap him in the face, in a manner of speaking:
17459765723452353453534535353530530534563507309676764423 ??? ??? ??? ??? ??? 17459765723452353453534535353530530534563507309676764423 ??? ??? ??? ??? ???
To achieve that, we will simply ignore any leading zeros. Once we find a non–zero digit, we will initialize a counter to <constant>0</constant> and start taking three steps: برای این کار، ما به‌سادگی صفرهای ابتدایی را نادیده می‌گیریم. همین که یک رقم غیر صفر پیدا کردیم، یک شمارنده را به <constant>0</constant> مقداردهی می‌کنیم و شروع به انجام سه مرحلهٔ زیر می‌کنیم:
Send the digit to the output. ارسال رقم به خروجی.
Append the digit to a buffer we will use later to produce the packed decimal we can send to the <acronym>FPU</acronym>. اضافه کردن رقم به یک میانگیر که دیرتر برای تولید مقدار ده‌دهیِ بسته‌بندی شده‌ای که می‌توانیم به <acronym>FPU</acronym> ارسال کنیم استفاده خواهیم کرد.
Increase the counter. افزایش شمارنده.
Now, while we are taking these three steps, we also need to watch out for one of two conditions:
If the counter grows above 18, we stop appending to the buffer. We continue reading the digits and sending them to the output.
If, or rather <emphasis>when</emphasis>, the next input character is not a digit, we are done inputting for now.
Incidentally, we can simply discard the non–digit, unless it is a <constant>#</constant>, which we must return to the input stream. It starts a comment, so we must see it after we are done producing output and start looking for more input.
That still leaves one possibility uncovered: If all the user enters is a zero (or several zeros), we will never find a non–zero to display.
We can determine this has happened whenever our counter stays at <constant>0</constant>. In that case we need to send <constant>0</constant> to the output, and perform another "slap in the face":
0 ??? ??? ??? ??? ??? 0 ??? ??? ??? ??? ???
Once we have displayed the focal length and determined it is valid (greater than <constant>0</constant> but not exceeding 18 digits), we can calculate the pinhole diameter.
It is not by coincidence that <emphasis>pinhole</emphasis> contains the word <emphasis>pin</emphasis>. Indeed, many a pinhole literally is a <emphasis>pin hole</emphasis>, a hole carefully punched with the tip of a pin.
That is because a typical pinhole is very small. Our formula gets the result in millimeters. We will multiply it by <constant>1000</constant>, so we can output the result in <emphasis>microns</emphasis>.
At this point we have yet another trap to face: <emphasis>Too much precision.</emphasis>
Yes, the <acronym>FPU</acronym> was designed for high precision mathematics. But we are not dealing with high precision mathematics. We are dealing with physics (optics, specifically).
Suppose we want to convert a truck into a pinhole camera (we would not be the first ones to do that!). Suppose its box is <constant>12</constant> meters long, so we have the focal length of <constant>12000</constant>. Well, using Bender's constant, it gives us square root of <constant>12000</constant> multiplied by <constant>0.04</constant>, which is <constant>4.381780460</constant> millimeters, or <constant>4381.780460</constant> microns.
Put either way, the result is absurdly precise. Our truck is not <emphasis>exactly</emphasis> <constant>12000</constant> millimeters long. We did not measure its length with such a precision, so stating we need a pinhole with the diameter of <constant>4.381780460</constant> millimeters is, well, deceiving. <constant>4.4</constant> millimeters would do just fine.

Loading…

Append the digit to a buffer we will use later to produce the packed decimal we can send to the <acronym>FPU</acronym>.
اضافه کردن رقم به یک میانگیر که دیرتر برای تولید مقدار ده‌دهیِ بسته‌بندی شده‌ای که می‌توانیم به <acronym>FPU</acronym> ارسال کنیم استفاده خواهیم کرد.
3 months ago
Browse all component changes

Glossary

English Persian
Buffer Overflow سرریز میان‌گیر FreeBSD Doc

Source information

Source string comment
(itstool) path: step/para
Source string location
book.translate.xml:13306
String age
6 months ago
Source string age
a year ago
Translation file
books/fa/developers-handbook.po, string 2091