×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    62

    how can avoid this rounding off in TReal

    TRealFormat format;
    format.iType = KRealFormatFixed|KDoNotUseTriads;
    format.iPlaces = 2;

    TReal Value1;
    TReal Value2;
    TReal Value3;
    TBuf<50>CurrencyShortName

    Value2= iSettings->iCurrencies->operator [](i).iCurrencyToBase;
    Value3=Value2/Value1;
    CurrencyShortName.AppendNum(Value3,format);
    iLabelval2->SetTextL(CurrencyShortName


    if Value1=40.05,Value2=0.64
    it is given value3=0.0159823343

    i want only 0.01 into buffer for which i am using TRealFormat but it Round off the value and give 0.02 .
    how can i avoid this rounding off.so tht i can get 0.01 .

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: how can avoid this rounding off in TReal

    When programming in BASIC in such situation I was multiplying the number with 100, truncated the fractional part (Math::Int can do that for you), then divided back the result with 100.
    I guess it would still work in Symbian C++, though if you round 0.015xxx to 2 decimal digits, the result should be 0.02 indeed - so now I would be satisfied with the default behavior.

Similar Threads

  1. Convert TReal to TDesc
    By mcadirci in forum Symbian
    Replies: 9
    Last Post: 2009-03-19, 09:03
  2. Replies: 6
    Last Post: 2009-03-15, 13:36
  3. Reading TReal from file on Nokia's Series 60
    By doctordwarf in forum Symbian
    Replies: 1
    Last Post: 2003-10-19, 16:41
  4. Replies: 0
    Last Post: 2003-10-17, 18:29
  5. Avoid repling back to the sms
    By sunil_90 in forum General Messaging
    Replies: 1
    Last Post: 2002-12-17, 06:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×