TRUNC


Truncates a number by removing decimal places.

Syntax:

TRUNC(number, places)

returns number with at most places decimal places. Excess decimal places are simply removed, irrespective of sign. TRUNC(number; 0) behaves as INT(number) for positive numbers, but effectively rounds towards zero for negative numbers.

Example:

TRUNC(1.239, 2)

returns 1.23. The 9 is lost.

TRUNC(-1.234999, 3)

returns -1.234. All the 9s are lost.


Application:

Let's consider an application for TRUNC in the context of inventory management for a retail store. Imagine a store that sells items in bulk, but sometimes they need to calculate how many full, complete packages they can create from a given amount of raw material.


Scenario: A pet store sells dog food in 5 kg bags. They receive a large shipment of dog food in a single bulk container and need to determine how many full bags they can fill.


Table: Bulk Inventory

Product ID

Product Name

Total Weight KG

Bag Size KG

A
B
C
D
1
101
Dog Food
234.7
5
2
102
Cat Food
150.3
2
3
103
Bird Seed
78.9
1

To find the number of full bags of dog food that can be created, we can use the TRUNC function. The calculation would be Total_Weight_KG / Bag_Size_KG. If we simply perform this division, we would get a number with a decimal, which represents the total number of bags including a partially filled one. However, the store is only interested in the number of complete bags.


Here's how the TRUNC function would be applied:

Product ID

Product Name

Total Weight KG

Bag Size KG

Full Bags Possible

A
B
C
D
E
1
101
Dog Food
234.7
5
46
2
102
Cat Food
150.3
2
75
3
103
Bird Seed
78.9
1
78

Explanation:

  • For Dog Food, 234.7 / 5 equals 46.94. The TRUNC function discards the .94, leaving 46. This tells the store they can fill 46 full 5 kg bags. The remaining 0.94 * 5 = 4.7 kg would be leftover material.
  • For Cat Food, 150.3 / 2 equals 75.15. The TRUNC function truncates this to 75, indicating 75 full bags can be made with some leftover.
  • For Bird Seed, 78.9 / 1 equals 78.9. The TRUNC function gives us 78, meaning they can fill 78 full 1 kg bags.


This example clearly demonstrates the practical use of TRUNC to get a whole number result by simply chopping off the decimal part, which is crucial for inventory calculations where partial units are not counted as "complete" items.





This page is protected by Google reCAPTCHA. Privacy - Terms.
 
Built using Zapof