JavaScript Number Precision, BigInt, and Formatting for Pythonistas

Stephen Gruppetta 16 Lessons 2h 52m Updated intermediate js py

Python’s Decimal keeps money exact, and a JavaScript port to plain numbers mostly looks the same. Swap the invoice script’s Decimal() calls for Number(), and every café’s amount still prints correctly, but the month total no longer equals the web shop’s: the script prints Check the export: €1,303.20 here, €1303.20 in the shop, with no error.

In this course, you’ll port the roastery’s month-end invoice script, which prints each café’s kilos, share, amount, payment reference, and orders from the web shop’s export, from Python to JavaScript.

By the end of this course, you’ll be able to:

  • Add up weights and money so the totals match Python’s, using whole units and integer cents
  • Keep 19-digit order numbers exact, and compute check digits with BigInt
  • Catch a result that comes out as Infinity or NaN with Number.isFinite()
  • Round the way Python does with roundingMode, and format shares, signs, and units with Intl.NumberFormat
  • Port the whole invoice script to JavaScript

You’ll need Python’s Decimal and format specs such as :.2f and :.0%, and know that floats don’t always add up exactly and ints have no size limit. In JavaScript, you’ll need Node 26 and the number basics: the number type, Math, Number(), and Intl.NumberFormat with the currency and percent styles. The Python examples use Python 3.15.

The course mixes short videos and text lessons with exercises, a project that ports the whole invoice script, and a quiz.

What’s Included:

  • 16 Lessons
  • Video Subtitles and Full Transcripts
  • Translated Subtitles in 8 Languages
  • 2 Downloadable Resources
  • Interactive Quiz to Check Your Progress
  • 5 Hands-On Coding Exercises
  • Q&A With JavaScript Experts: Ask a Question
  • Certificate of Completion

Downloadable Resources:

Related Learning Paths:

About Stephen Gruppetta

Stephen obtained a PhD in physics and worked as a physicist in academia for over a decade before becoming a programming educator. He's constantly looking for simple ways to explain complex things.

» More about Stephen

← Browse All Courses