2010-08-03 1 views

답변

0

:


class DOBLE 

creation 
    make 

feature 
    make is 
     local 
      n: DOUBLE 
      output: STRING 
     do 
      n := 118.1999999999999 
      output := n.to_string_format(2) -- 2 digits in fractionnal part 
      std_output.put_string(output + "%N") 
     end 
end 
2

당신은

등등

local 
    fd: FORMAT_DOUBLE 
do 
    create fd.make (5, 3) 
    print (fd.formatted ({REAL_64} 12345.6789)) --> "12345.679" 
    print (fd.formatted ({REAL_64} 12345.6)) --> "12345.600" 
    print (fd.formatted ({REAL_64} 0.6)) --> "0.600" 

    create fd.make (10, 2) 
    fd.right_justify 
    print (fd.formatted ({REAL_64} 1.678)) --> "  1.68" 

    create fd.make (20, 3) 
    fd.right_justify 
    print ("[" + fd.formatted ({REAL_64} 12345.6789) + "]%N") --> [   12345.679] 
    fd.left_justify 
    print ("[" + fd.formatted ({REAL_64} 12345.6789) + "]%N") --> [12345.679   ] 
    fd.center_justify 
    print ("[" + fd.formatted ({REAL_64} 12345.6789) + "]%N") --> [  12345.679  ] 
FORMAT_DOUBLE 클래스를 사용해야합니다 ... "의 printf"을 모방하는 클래스 세트도 있습니다

, 당신은 그들을 http://www.amalasoft.com/downloads.htm 에서 찾을 수 있습니다. 나는 그들 자신을 사용하지 않았지만 그것은 당신의 필요를 해결할 것입니다.

는 이전 응답 어디에서 오는지 나는 확실하지 않다 (ECMA 에펠를 사용하고 있지만, DOUBLE는 기능`to_string_format이 없습니다 '. 그리고 두 번 REAL_64

의 옛 이름입니다
관련 문제