{"id":20716,"date":"2017-03-28T20:40:21","date_gmt":"2017-03-28T20:40:21","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=20716"},"modified":"2017-03-28T20:40:21","modified_gmt":"2017-03-28T20:40:21","slug":"perl-int-function-isolating-a-digit","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/perl-int-function-isolating-a-digit\/","title":{"rendered":"Perl:  int() function:  isolating a digit"},"content":{"rendered":"<h1>Tutoring computer science, extracting a digit is a suggested exercise.  The tutor shows a use of Perl&#8217;s int() function.<\/h1>\n<p>Let&#8217;s imagine you want to find the hundred-thousands digit of an input number.  You can do so with the following code:<\/p>\n<p style=\"font-family:monospace;color:#550077\">$digit=(int($input_number\/100000))%10;<\/p>\n<p>In the code above, the $input_number is first divided by 100000, which will likely give a decimal.  Then, int() simply removes the decimal places, but doesn&#8217;t round.  Next, %10 gives the remainder when the result is divided by 10.  This is needed if the input number is a place past the hundred thousands; eg., the millions, ten millions, etc.<\/p>\n<p>HTH:)<\/p>\n<p>McGrath, Mike.  <u>Perl in easy steps<\/u>.  Southam:  Computer Step, 2004.<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tutoring computer science, extracting a digit is a suggested exercise. The tutor shows a use of Perl&#8217;s int() function. Let&#8217;s imagine you want to find the hundred-thousands digit of an input number. You can do so with the following code: &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/perl-int-function-isolating-a-digit\/\"> <span class=\"screen-reader-text\">Perl:  int() function:  isolating a digit<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[2202,2203,104],"class_list":["post-20716","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-int-function","tag-isolating-a-digit","tag-perl"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/20716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=20716"}],"version-history":[{"count":10,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/20716\/revisions"}],"predecessor-version":[{"id":20726,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/20716\/revisions\/20726"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=20716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=20716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=20716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}