asScientific() public méthode

Formats the value as a scientific number.
public asScientific ( mixed $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string
$value mixed the value to be formatted.
$decimals integer the number of digits after the decimal point.
$options array optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]].
$textOptions array optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
Résultat string the formatted result.
 public function testAsScientific()
 {
     $value = '123';
     $this->assertSame('1.23E2', $this->formatter->asScientific($value));
     $value = '123456';
     $this->assertSame("1.23456E5", $this->formatter->asScientific($value));
     $value = '-123456.123';
     $this->assertSame("-1.23456123E5", $this->formatter->asScientific($value));
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asScientific(null));
 }
Exemple #2
0
 public function testAsScientific()
 {
     if (defined('HHVM_VERSION')) {
         // the default format is different on HHVM
         $this->markTestSkipped('HHVM behaves quite different in the default patterns used for formatting.');
     }
     $value = '123';
     $this->assertSame('1.23E2', $this->formatter->asScientific($value));
     $value = '123456';
     $this->assertSame("1.23456E5", $this->formatter->asScientific($value));
     $value = '-123456.123';
     $this->assertSame("-1.23456123E5", $this->formatter->asScientific($value));
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asScientific(null));
 }
Exemple #3
0
 public function testAsScientific()
 {
     $value = '123';
     $this->assertSame('1.23E+2', $this->formatter->asScientific($value, 2));
     $value = '123456';
     $this->assertSame("1.234560E+5", $this->formatter->asScientific($value));
     $value = '-123456.123';
     $this->assertSame("-1.234561E+5", $this->formatter->asScientific($value));
     // empty input
     $this->assertSame("0.000000E+0", $this->formatter->asScientific(false));
     $this->assertSame("0.000000E+0", $this->formatter->asScientific(""));
     // null display
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asScientific(null));
 }