---
title: "NSDecimalDivide(_:_:_:_:)"
framework: foundation
role: symbol
role_heading: Function
path: "foundation/nsdecimaldivide(_:_:_:_:)"
---

# NSDecimalDivide(_:_:_:_:)

Divides one decimal value by another.

## Declaration

```swift
func NSDecimalDivide(_ result: UnsafeMutablePointer<Decimal>, _ leftOperand: UnsafePointer<Decimal>, _ rightOperand: UnsafePointer<Decimal>, _ roundingMode: NSDecimalNumber.RoundingMode) -> NSDecimalNumber.CalculationError
```

## Discussion

Discussion Divides leftOperand by rightOperand and stores the quotient, possibly rounded off according to roundingMode, in result. If rightOperand is 0, returns NSDivideByZero. For explanations of the possible return values and rounding modes, see NSDecimalAdd(_:_:_:_:). Note that repeating decimals or numbers with a mantissa larger than 38 digits cannot be represented precisely. For more information, see Number and Value Programming Topics.

## See Also

### Performing arithmetic using references

- [NSDecimalCompact(_:)](foundation/nsdecimalcompact(_:).md)
- [NSDecimalAdd(_:_:_:_:)](foundation/nsdecimaladd(_:_:_:_:).md)
- [NSDecimalSubtract(_:_:_:_:)](foundation/nsdecimalsubtract(_:_:_:_:).md)
- [NSDecimalMultiply(_:_:_:_:)](foundation/nsdecimalmultiply(_:_:_:_:).md)
- [NSDecimalMultiplyByPowerOf10(_:_:_:_:)](foundation/nsdecimalmultiplybypowerof10(_:_:_:_:).md)
- [NSDecimalRound(_:_:_:_:)](foundation/nsdecimalround(_:_:_:_:).md)
- [NSDecimalPower(_:_:_:_:)](foundation/nsdecimalpower(_:_:_:_:).md)
- [NSDecimalNormalize(_:_:_:)](foundation/nsdecimalnormalize(_:_:_:).md)
- [Decimal.RoundingMode](foundation/decimal/roundingmode.md)
- [NSDecimalNumber.RoundingMode](foundation/nsdecimalnumber/roundingmode.md)
- [Decimal.CalculationError](foundation/decimal/calculationerror.md)
- [NSDecimalNumber.CalculationError](foundation/nsdecimalnumber/calculationerror.md)
