FastPrepReal-Number Calculator
Problems/Real-Number Calculator

Real-Number Calculator

NVIDIA logoNVIDIA● EasyINTERNPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names a real-number calculator but gives no operations, syntax, or edge rules. This four-operation practice matches the reported core at about 40%.

Implement a calculator for real numbers. For this exercise, assume each request contains two operands, left and right, and one arithmetic operation operation.

  • "+": return left + right.
  • "-": return left - right.
  • "*": return left * right.
  • "/": return left / right using real-number division.

For this exercise, assume every request is valid: the operation is one of these four symbols, and a division request has a nonzero divisor. Evaluate just this one operation; there is no expression string to parse.

Return a double-precision result. An answer is accepted when its absolute error is at most 10^-6 * max(1, abs(expected)). Do not round the answer to a fixed number of decimal places.

Function

calculateReal(left: double, operation: String, right: double) → double

Examples

Example 1

left = 2.5operation = "+"right = 1.75return = 4.25

Adding 2.5 and 1.75 gives 4.25.

Example 2

left = -3.5operation = "-"right = 2return = -5.5

Subtracting 2 from -3.5 gives -5.5.

Example 3

left = 1.2operation = "*"right = -2.5return = -3

Multiplying 1.2 by -2.5 gives -3.

Example 4

left = 7.5operation = "/"right = 2return = 3.75

Real-number division gives 7.5 / 2 = 3.75.

Constraints

  • -10^6 <= left <= 10^6.
  • -10^6 <= right <= 10^6.
  • Both operands are finite real numbers.
  • operation.length == 1, and operation is one of "+", "-", "*", or "/".
  • When operation == "/", abs(right) >= 10^-6.

More NVIDIA Phone Screen questions

  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
  • Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
  • Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
  • Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
  • Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
  • Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
  • Merge Multiple Sorted StreamsPHONE SCREEN · Seen Aug 2026
  • Linked List Palindrome in Constant SpacePHONE SCREEN · Seen Aug 2026
  • LRU Key-Value Cache OperationsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Circular Primes Below a LimitAmazon · PHONE SCREEN
  • Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
  • Streaming AverageXantium · PHONE SCREEN
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Newton Square Root to a Guaranteed ToleranceSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions

Interview reports that mention this question

  • NVIDIA Software Intern Interview Questions: 9 Experiences

NVIDIA interview experiences

  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public double calculateReal(double left, String operation, double right) {
        // Write your code here.
    }

}
Checking account…