{"id":2087,"date":"2015-01-06T10:44:43","date_gmt":"2015-01-06T09:44:43","guid":{"rendered":"http:\/\/roboblog.fatal-fury.de\/?page_id=2087"},"modified":"2015-01-08T03:02:31","modified_gmt":"2015-01-08T02:02:31","slug":"fortran-c-java","status":"publish","type":"page","link":"http:\/\/roboblog.fatal-fury.de\/?page_id=2087","title":{"rendered":"Fortran C++ Java"},"content":{"rendered":"<p><strong>Functions<\/strong><br \/>\nFortran:<br \/>\nC++<\/p>\n<p><strong>Class<\/strong><\/p>\n<p><strong>Conversion<\/strong><br \/>\nAsign a double to a float should trigger a warning. Due to the reduced precision of float. Asign a integer to a float should also warn. There exist big integers which cannot stored in float without loose of the last digits.<br \/>\nThere are 4 different cases:<br \/>\n1) integer constant to float<br \/>\n2) integer variable to float<br \/>\n3) double constant to float<br \/>\n4) double variable to float<\/p>\n<p>Fortran:<\/p>\n<pre><code>    integer :: i\r\n    real(4) :: a\r\n    real(8) :: b\r\n\r\n    a = 1\r\n    a = 100000001a\r\n    a = i\r\n    a = 0.1234567890123_8\r\n    a = b\r\n<\/code><\/pre>\n<p>C++<\/p>\n<pre><code>  int i;\r\n  float a;\r\n  double b;\r\n\r\n  a = 1;\r\n  a = 100000001;\r\n  a = i;\r\n  a = 0.1234567890123;\r\n  a = b;\r\n<\/code><\/pre>\n<pre>\r\ngfortran  fortran.F90 -Wconversion -Wconversion-extra\r\nfortran.F90:20.8:\r\n\r\n    a = 1\r\n        1\r\nWarning: Conversion from INTEGER(4) to REAL(4) at (1)\r\nfortran.F90:21.8:\r\n\r\n    a = 100000001\r\n        1\r\nWarning: Conversion from INTEGER(4) to REAL(4) at (1)\r\nfortran.F90:22.8:\r\n\r\n    a = i\r\n        1\r\nWarning: Conversion from INTEGER(4) to REAL(4) at (1)\r\nfortran.F90:23.8:\r\n\r\n    a = 0.1234567890123_8\r\n        1\r\nWarning: Change of value in conversion from  REAL(8) to REAL(4) at (1)\r\nfortran.F90:24.8:\r\n\r\n    a = b\r\n        1\r\nWarning: Conversion from REAL(8) to REAL(4) at (1)\r\n\r\n<\/pre>\n<pre><code>\r\n<\/code><\/pre>\n<p><strong>Initializer lists<\/strong><br \/>\nFortran:<\/p>\n<pre><code>Module TestModule\r\n  contains\r\n  subroutine func(list)\r\n    implicit none\r\n    integer, intent(in) :: list(:)\r\n\r\n    write(*,*) list\r\n  end subroutine\r\nend module\r\n\r\nprogram testprogrm\r\n  use TestModule\r\n  implicit none\r\n\r\n  call func( <strong>(\/1,2,3\/)<\/strong> ) \r\nend program\r\n<\/code><\/pre>\n<pre>\r\n$ gfortran -Wall -Wextra -fcheck=all fortran.F90\r\n$ .\/a.out \r\n           1           2           3\r\n<\/pre>\n<p>C++<\/p>\n<pre><code>#include < iostream >\r\n#include < initializer_list >\r\n\r\nvoid func(std::initializer_list<int> list) {\r\n  for(int x: list) std::cout << x << ' ';\r\n}\r\n\r\nint main() {\r\n  func( <strong>{1,2,3}<\/strong> );\r\n}\r\n<\/code><\/pre>\n<pre>\r\n$ g++ -Wall -Wextra -std=c++11 cpp.cpp\r\n$ .\/a.out \r\n1 2 3\r\n<\/pre>\n<p><strong>(Strongly typed) enumerations<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Functions Fortran: C++ Class Conversion Asign a double to a float should trigger a warning. Due to the reduced precision of float. Asign a integer to a float should also warn. There exist big integers which cannot stored in float without loose of the last digits. There are 4 different cases: 1) integer constant to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2087","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/pages\/2087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2087"}],"version-history":[{"count":10,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/pages\/2087\/revisions"}],"predecessor-version":[{"id":2105,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/pages\/2087\/revisions\/2105"}],"wp:attachment":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}