Help for this page

Select Code to Download


  1. or download this
      $x = 0.54 ; print "$x: ", ($x * 100) - int($x * 100), "\n" ;  # 0.54
    +: 0
      $x = 0.56 ; print "$x: ", ($x * 100) - int($x * 100), "\n" ;  # 0.56
    +: 7.105427357601e-15
      $x = 0.58 ; print "$x: ", ($x * 100) - int($x * 100), "\n" ;  # 0.58
    +: 0.999999999999993
    
  2. or download this
      int(abs($_[0]) * 10**$D + 0.5) % 10**($D-2)
    
  3. or download this
      use POSIX qw(fmod) ;
      fmod(int(abs($_[0]) * 10**$D + 0.5), 10**($D-2))
    
  4. or download this
      $x = 0+sprintf('%0.6f', $x) ;  # 6 decimal places
      $x = 0+sprintf('%1.5e', $x) ;  # 6 significant digits