4D Blog

Home Product Convert Numbers with Ease: Enhanced String and Num Commands

Convert Numbers with Ease: Enhanced String and Num Commands

October 17, 2025

Product

When working with different numeric bases, such as binary or hexadecimal, converting between numbers and strings is a common task. With 4D 21, the String and Num commands have been enhanced to make these conversions more powerful.

Convert a number to a string in any base

The String command now supports conversion from an integer to a string in any base from 2 to 36. This makes it simple to represent values in binary, octal, decimal, hexadecimal, and beyond.

var $result := String(6; 2)
// "110" — binary representation of 6

$result := String(254; 16)
// "fe" — hexadecimal representation of 254

$result := String(14256; 36)
// "b00" — base 36 representation of 14256 

Convert a string to an integer

The Num command now also supports parsing strings in any base from 2 to 36. This is especially helpful when working with hexadecimal or binary inputs.

var $result:=Num("110";2) 
// $result = 6 
$result:=Num("fe";16)
// $result = 254

$result:=Num("b00";36)
// $result = 14256

Note: Since Num uses the historical 4D algorithm when no base is specified, and the ECMAScript algorithm when a base is provided, you might notice differences with very large numbers like 1e+25 and beyond.

Conclusion

Whether you’re building a developer tool, debugging protocols, or just displaying numbers in a more readable format, these enhancements offer more flexibility and control. Now you can easily switch between numeric bases, validate user input, or serialize data in formats like hexadecimal or binary natively in 4D.

Discuss

Tags 21, conversion, Language

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy