Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding a value to 2dp in RAVE 2

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
AU
Is there a way to round a value down to two decimal places...

I am getting values from 1.4489871613 and i want to shorten it down to 1.45

any ideas
 
Sorry,

maybe i wasn't clear enough i was refering to a SQL value that has been moved into RAVE reports

or is there an SQL method through the ADO query function
 
if you write "RoundTo(14.345, -2)" then the result will be
14.34, not 14.35
You might give a little offset to adjust the result:

"RoundTo(14.345 + 0.0000001, -2)" Result -> 14.35

Does anyone else know how to manage that little detail?

// Example-Prog
procedure TfMain.btnRoundClick(Sender: TObject);
const korrOffs: Double = 0.0000001;
var aDouble1, aDouble2: Double;
begin
aDouble1 := RoundTo(14.345, -2);// = 14.34
aDouble2 := RoundTo(14.345 + korrOffs, -2);//= 14.35
MessageDlg('Round_1: 14.345 -> '+ FloatToStr(aDouble1)
, mtWarning, [mbOK], 0);//->14.34

MessageDlg('Round_2: 14.345 -> '+ FloatToStr(aDouble2)
, mtWarning, [mbOK], 0);//->14.35
end;
 
look at this :

Setroundmode

Sets the FPU rounding mode.

Unit

Math

Category

FPU control

Delphi syntax:

type TFPURoundingMode = (rmNearest, rmDown, rmUp, rmTruncate);
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;

C++ syntax:

enum TFPURoundingMode {rmNearest, rmDown, rmUp, rmTruncate}
extern PACKAGE TFPURoundingMode __fastcall SetRoundMode(const TFPURoundingMode RoundMode);

Description

Call SetRoundingMode to specify how the FPU handles rounding issues. The rounding mode can be any of the following values:

Value Meaning

rmNearest Rounds to the closest value.
rmDown Rounds toward negative infinity.
rmUp Rounds toward positive infinity.
rmTruncate Truncates the value, rounding positive numbers down and negative numbers up.

 
HELLO?

Anybody listening to me???

I KNOW HOW TO ROUND IN DELPHI!!!!

I am looking to see if anybody knows how to reound in the SQL area of an ADO Query or in the RAVE REPORTING system.
 
sorry PaidTheUmpire, I was only responding to nyff2's question. what concerns your question : there also exists a round function in SQL. you can use it like this :

SELECT ROUND(yourvalue,2) FROM yourtable
....

hope this helps,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top