I am writing a web app that is converting SQL data in the form of text (dollar amounts) to numbers, then totalling. However, I've come across only certain values that round very oddly!   I have a JSFiddle to show this (with more values than below) as well as sample code below, using text vars as I would be pulling from SQL data.  JSFiddle     I've done what I've seen recommended here by various people and multiplied values by 100 to work with integers only - hoping to avoid rounding issues. I've tried various combinations of Number() and toFixed etc but can't seem to get a handle on the best way to avoid rounding issues in JS. Most values are fine, but I accidentally came across '129.42' being an issue.  I have no idea what other numbers might also cause problems leaving my app totally unreliable!!  This is very peculiar behaviour!?  HTML:  &lt;html&gt; &lt;body id='body'&gt; Example of NASTY rounding in JavaScript: &lt;br&gt;&lt;br&gt; &lt;/body&gt; &lt;/html&gt;   JS:  var ary = [ '129.42', '129.45', '125.42', '125.45', '130.42']; var div; for (var x in ary) {   var text = ary[x];   var num = parseInt(Number(text)*100);    div = document.createElement('div');   div.innerHTML = 'Original "text" number: '+text;   document.getElementById('body').appendChild(div);    div = document.createElement('div');   div.innerHTML = 'Multiply by 100 and Converted to Integer: '+num+'&lt;br&gt;&lt;br&gt;';   document.getElementById('body').appendChild(div);  }   The above results in:  Example of NASTY rounding in JavaScript:   Original "text" number: 129.42 Multiply by 100 and Converted to Integer: 12941  Original "text" number: 129.45 Multiply by 100 and Converted to Integer: 12944  Original "text" number: 125.42 Multiply by 100 and Converted to Integer: 12542  Original "text" number: 125.45 Multiply by 100 and Converted to Integer: 12545  Original "text" number: 130.42 Multiply by 100 and Converted to Integer: 13041
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
Changing projection of shapefile in QGIS How do I change the projection of my shapefile using QGIS? The default projection is set to EPSG:3003, I want to change it to WGS84 EPSG:32632. When I do a reprojection or I change projection in the properties mask I don't have the correct result. On the left, I have the plan coordinates but they are not correct for the EPSG shown on the right: Make a file pointer read/write to an in-memory location Best way to extract a subvector from a vector? I have the amulet of Mara but when I go to talk to maramal about a wedding nothing shows up. WHY is that. How to mount read-write an ext4 partition on Windows? Some proof question about Fibonacci sequence New tab in chromium is empty I am still learning settings API so please forgive my noob question. I have three fields: a checkbox, colorpicker and text field (they are working), but I would like to do this: when the theme is installed add "checked" state to my checkbox but allow user to "unchecked" it ,and if empty add default color to my colorpicker... I have no idea how to do this so please help me!  My code looks like this now (thanks to @Chip Bennett! ) :  &lt;?php add_action('admin_menu','create_theme_options_page'); function create_theme_options_page(){ add_options_page('Theme Options','Theme Options','administrator',__FILE__,'build_options_page'); }    function build_options_page(){    ?&gt;    &lt;div id="theme-options-wrap"&gt;    &lt;div style="float:left;margin-top:19px;position:absolute;" class="icon32" id="icon-tools"&gt;&lt;br/&gt;&lt;/div&gt;    &lt;h2&gt;My options page&lt;/h2&gt;    &lt;form method="post" action="options.php"&gt;    &lt;?php settings_fields('plugin_options');?&gt;    &lt;?php do_settings_sections(__FILE__); ?&gt;    &lt;p class="submit"&gt;    &lt;input name="Submit" type="submit" class="button-primary" value="&lt;?php esc_attr_e('Save changes');?&gt;"/&gt;    &lt;/p&gt;    &lt;/form&gt;    &lt;/div&gt;    &lt;?php    }       add_action('admin_init','register_and_build_fields');      function register_and_build_fields(){      register_setting('plugin_options','plugin_options','validate_setting');      add_settings_section('main_section','&lt;br/&gt;&lt;br/&gt;Main Settings','section_cb',__FILE__);      add_settings_field('banner_heading','Banner Heading:','banner_heading_setting',__FILE__,'main_section');      add_settings_field('display_sidebar','Display Sidebar:','display_sidebar_setting',__FILE__,'main_section');      add_settings_field('display_colorpicker','Display Colorpicker:','display_colorpicker_setting',__FILE__,'main_section');      }        //Install Iris colorpicker        add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' );        function mw_enqueue_color_picker( $hook_suffix ) {        // first check that $hook_suffix is appropriate for your admin page        wp_enqueue_style( 'wp-color-picker' );        wp_enqueue_script( 'my-script-handle', get_template_directory_uri() . '/js/my-script.js', array( 'wp-color-picker' ), false, true );        }           //Colorpicker          //Now how to add a default color on theme install?          function display_colorpicker_setting(){          $options = get_option('plugin_options');          echo"&lt;input type='text' id='color1' name='plugin_options[display_colorpicker]' value='{$options['display_colorpicker']}'/&gt;";          }            //Sidebar checkbox           //Now how to add a default state "checked" on theme install?           function display_sidebar_setting(){           $options = get_option('plugin_options');           echo "&lt;input type='checkbox' name='plugin_options[display_sidebar]' {$options['display_sidebar']} id='display_sidebar' /&gt;";           }              //Banner Heading             function banner_heading_setting(){             $options = get_option('plugin_options');             echo "&lt;input name='plugin_options[banner_heading]' type='text' value='{$options['banner_heading']}'/&gt;";             }               //Validate our settings here               function validate_setting($plugin_options){                  return $plugin_options;               }                 function section_cb(){                } ?&gt; What books, journals, and/or electronic resources have you found most valuable for expanding your knowledge in the GIS field, and why? system() has been disabled error message I have a small issue with configuring the lidR  for parametrizing the extracted raster files with grid_metrics() function.  My question is how to set in the catalog options that:   be able to overwrite the results with a second run if I want to run my script several times and I do not want to name each output differently. instead of .tif I would like to get .grd files as output.   My current code (which is working) is the following:  normalizedctg = catalog(workingdirectory) opt_output_files(normalizedctg) &lt;- paste(workingdirectory,"/clipped/normalized/{XLEFT}_{YBOTTOM}_height",sep="") height = grid_metrics(normalizedctg, max(Z),res = resolution)   But with a second run on the same code I get the following error:  Error in .getGDALtransient(x, filename = filename, options = options,  :    filename exists; use overwrite=TRUE I have a 24/7 always-on Debian Jessie based headless home server that has a large 1TB SSD for the OS and all of my frequently accessed files. This same system has 4 larger hard disk drives in a SnapRAID array. These are mainly for archiving infrequently accessed Blu-rays and want those drives to remain spun down in standby unless I actually read or write to them. They are all formatted as ext4 and mounted with noatime and nodiratime enabled.  So even though no process or program should be regularly accessing those drives in any direct way, the hard drives constantly get spun up from standby. It seems to be related to graphical programs that provide a gui file browser, even something like Chromium. If I don't even browse into those drives, I'm thinking that these processes by simply getting a list of available drives spins up the hard disks. Much like blkid does. The problem is, it's hard to determine the root cause of this since none of these processes are actually reading or writing the filesystem on those drives, so no files are actually changing or being touched. Is there some sort of cache that I can populate or a buffer to prevent these programs from spinning up the hard drive simply by getting a list of available disks? This is honestly driving me insane, since I can't find a reliably way to keep these disks spun-down even though there is no direct access of the filesystem.  UPDATE: Thanks to Stephen's answer, I was able to trace the disk activity to gvfs and udisks. It's a real shame that these processes insist on waking up disks in standby when they aren't actually being accessed to do any real I/O with the filesystem. So far I just uninstalled them, knowing that it will remove some functionality from PCManFM and the like. $\newcommand{\P}{\mathbb{P}}$Is it valid to interpret $\P(B|A)$ as "infinite probability" when $\P(A) = 0$? To explain the expansion of space I have often heard people saying that space is continuously created. This picture is usually applied to cosmological scales but I`m nevertheless curious if some microscopic description of this process could be found (or probably is already available?).  The first thing which comes into my mind by thinking about this is that in theories like loop quantum gravity, there is an idea that space is quantized. Would space expansion then be explained as the creation of new quanta in loop quantum cosmology? Or are there other different ideas, such as the quanta themselves changing properties? Do people actually working on this already have some interesting results? Converting expressions to polynomial form How do you detect support for VML or SVG in a browser I'm writing a bit of javascript and need to choose between SVG or VML (or both, or something else, it's a weird world). Whilst I know that for now that only IE supports VML, I'd much rather detect functionality than platform.  SVG appears to have a few properties which you can go for: window.SVGAngle for example.  Is this the best way to check for SVG support?  Is there any equivalent for VML?  Unfortuntaly - in firefox I can quite happily do all the rendering in VML without error - just nothing happens on screen. It's quite hard to detect that situation from script. "Belongs on" comments I'm trying to recall the title of a young adult-targeted book. It was probably published by Scholastic, or at least sold through their take-home pamphlets, which means it was probably published before I started high school in 1996. It's about a group of teenagers who receive invitations to play a game at an invitation-only arcade. When they go there, they are put in an immersive VR game in which they must learn to survive on an alien planet. I believe the game ends and they wake up back in the real world after they fall asleep on the alien one. They are invited back the the game a couple times, and then it turns out…      …they go to play the game again, but they are unable to exit it. Eventually they realize that they actually are on an alien planet now, and that the previous game-playing sessions were just training for the real thing. I believe the epilogue states that all of the players have coupled up and the females have become pregnant, and they are optimistic about populating the new planet.   I think it was told in the first-person perspective of a female player. I don't think there was a real protagonist or strong conflict; just the group of players learning how to survive in the game. One of the other players had a photographic memory and used it to map the planet's surface. I think the cover art featured of a girl wearing a VR headset over her eyes, with her hair being blown back and her mouth open in surprise. Wild Magic Surge - What does "You cast ..." mean for your spell slots? In response to  question, I started to think about what it means when a Wild Magic Surge results in a "You cast spell-X".  So, "specific beats general" gives:   You can cast a second spell when you would not normally be allowed to You can cast a spell you don't know If the surge forces you to cast a concentration spell you would lose any concentration spell that you currently had active Subject to what the specific entry says you can target it how you like Unless the specific entry prohibits it you could use metamagic on the spell   I am pretty confident in all of the above but if anyone disagrees please address in an answer.  Here comes the question.  How does this impact on your available spell slots?  "You cast ..." to me suggests that if you have an applicable slot available then you have to use it to cast the spell because that is the general rule for casting spells but if you don't then "specific beats general" and it is cast anyway.  Specific examples:     You cast fireball as a 3rd-level spell centered on   yourself   This must be a 3rd level spell:   if you have a 3rd level slot available you have to use it? if you don't, if you have 5 sorcery points and a bonus action available must you use these to get that slot? if you don't have any of that then the spell goes off anyway?      You cast confusion centered on yourself.   No level specified and confusion is a 4th level spell:   if you have a 4th level slot available you have to use it? if you have a 4th, a 6th and an 8th level slot you can choose which one to use? if you have only a 5th level slot but also 6 sorcery points and a bonus action, you could choose to use the 5th level slot or use the points to create a 4th level slot? if you don't have any 4th level or higher slots but you have 6 sorcery points and a bonus action available must you use these to get that slot? if you don't have any of that then the spell goes off anyway?   And so on ... Why is the network configuration I set in /etc/network/interfaces ignored on Ubuntu 17.10?