ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Truncating to two decimals (https://www.excelbanter.com/excel-programming/359911-truncating-two-decimals.html)

Phil H[_2_]

Truncating to two decimals
 
Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15

AA2e72E

Truncating to two decimals
 
try:
0.01*int( 897.15818*100)


"Phil H" wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15


Dana DeLouis

Truncating to two decimals
 
Is there a way to truncate to two decimals without rounding?

Here's one ideas:
=INT(A1*100)/100

but with rounding...
=ROUNDDOWN(A1,2)

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Phil H" wrote in message
...
Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15




MentalDrow

Truncating to two decimals
 
I use this if rounding isn't an issue

Range("B17:C21").Select
Selection.NumberFormat = "0.00%"
Range("I:I").Select
Selection.NumberFormat = "0.00%"


"Dana DeLouis" wrote:

Is there a way to truncate to two decimals without rounding?


Here's one ideas:
=INT(A1*100)/100

but with rounding...
=ROUNDDOWN(A1,2)

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Phil H" wrote in message
...
Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15





Ron Rosenfeld

Truncating to two decimals
 
On Wed, 26 Apr 2006 22:11:01 -0700, Phil H
wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15


As a worksheet formula, you could just use the TRUNC function:

e.g. =TRUNC(your_formula,2)

In VBA,

Int(your_formula * 100) / 100

or

Fix(your_formula * 100) / 100

depending on how you want to handle negative numbers.


--ron

[email protected]

Truncating to two decimals
 
=INT(A1*100)%

Regards,
Bernd


Phil H[_2_]

Truncating to two decimals
 
Thanks Ron, this is exactly what I needed.

"Ron Rosenfeld" wrote:

On Wed, 26 Apr 2006 22:11:01 -0700, Phil H
wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15


As a worksheet formula, you could just use the TRUNC function:

e.g. =TRUNC(your_formula,2)

In VBA,

Int(your_formula * 100) / 100

or

Fix(your_formula * 100) / 100

depending on how you want to handle negative numbers.


--ron


Ron Rosenfeld

Truncating to two decimals
 
Glad to help. Thanks for the feedback.



On Fri, 28 Apr 2006 00:13:01 -0700, Phil H
wrote:

Thanks Ron, this is exactly what I needed.

"Ron Rosenfeld" wrote:

On Wed, 26 Apr 2006 22:11:01 -0700, Phil H
wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15


As a worksheet formula, you could just use the TRUNC function:

e.g. =TRUNC(your_formula,2)

In VBA,

Int(your_formula * 100) / 100

or

Fix(your_formula * 100) / 100

depending on how you want to handle negative numbers.


--ron


--ron


All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com