disruptek / ryu

ryu for nim
MIT License
5 stars 2 forks source link

be consistent with nim, python, C , C++, go (etc) : Infinity => inf, NaN => nan, E => e #2

Closed timotheecour closed 4 years ago

timotheecour commented 4 years ago

/cc @disruptek to be consistent with: nim, python, C, C++, go, octave, matlab

C, C++

#include <iostream>
#include <stdio.h>

int main (int argc, char *argv[]) {
  // double x = 1.00001E25; // will print 1.00001e+25 not 1.00001E+25
  double x = 1.00001E25 / 0.0; // will print inf
  printf("%g\n", x);
  std::cout << x << std::endl;
  return 0;
}

python

import math
print(math.inf)
print(1.0E22) # 1e+22
print(math.inf) # inf

go

package main
import "fmt"
func main() {
    fmt.Println(1.00001E25) # 1.00001e+25
}

octave, matlab

octave:5> 112.0000**12
ans =    3.8960e+24