Skip to main content
ubuntuask.com

Back to all posts

How to Get Digits Past Decimal In Elixir?

Published on
2 min read
How to Get Digits Past Decimal In Elixir? image

Best Decimal Precision Tools to Buy in February 2026

1 SE Stainless Steel SAE Metric Ruler Set - Stainless Steel Precision Ruler Measuring Tool - Detachable Clips - Set of 2 Pcs - 925PSR-2

SE Stainless Steel SAE Metric Ruler Set - Stainless Steel Precision Ruler Measuring Tool - Detachable Clips - Set of 2 Pcs - 925PSR-2

  • DUAL-SCALE RULERS FOR PRECISION: MEASURE IN BOTH SAE AND METRIC EFFORTLESSLY.

  • QUICK CONVERSION MADE EASY: CONVERSION TABLES ENSURE ACCURATE MEASUREMENTS.

  • DURABLE DESIGN FOR ANY TASK: STAINLESS STEEL RULERS BUILT FOR LONG-LASTING USE.

BUY & SAVE
Save 7%
SE Stainless Steel SAE Metric Ruler Set - Stainless Steel Precision Ruler Measuring Tool - Detachable Clips - Set of 2 Pcs - 925PSR-2
2 PEC Tools 6" Rigid Steel Ruler, Precision Stainless Steel Ruler, 1/32" and 1/64" Markings on Front, with Decimal Equivalent Chart on Back, Made in USA

PEC Tools 6" Rigid Steel Ruler, Precision Stainless Steel Ruler, 1/32" and 1/64" Markings on Front, with Decimal Equivalent Chart on Back, Made in USA

  • ACHIEVE MAXIMUM PRECISION WITH 1/64 INCREMENTS FOR ACCURACY.
  • DURABLE STEEL CONSTRUCTION WITHSTANDS IMPACTS FOR RELIABLE USE.
  • LASER-ENGRAVED MARKINGS ENSURE CLARITY AND LONG-LASTING VISIBILITY.
BUY & SAVE
PEC Tools 6" Rigid Steel Ruler, Precision Stainless Steel Ruler, 1/32" and 1/64" Markings on Front, with Decimal Equivalent Chart on Back, Made in USA
3 PEC Tools 6" Stainless Steel Ruler, Machinist's Ruler, Round End Rule with Clip, 32nds-64ths of an inch, with Decimal Equivalent Chart on Back, Made in USA

PEC Tools 6" Stainless Steel Ruler, Machinist's Ruler, Round End Rule with Clip, 32nds-64ths of an inch, with Decimal Equivalent Chart on Back, Made in USA

  • PRECISION 1/64 INCREMENTS ENSURE ACCURATE MEASUREMENTS EVERY TIME.
  • FLEXIBLE DESIGN EASILY MEASURES CURVED SURFACES AND TIGHT SPACES.
  • DURABLE STAINLESS STEEL WITH SECURE POCKET CLIP FOR CONVENIENCE.
BUY & SAVE
PEC Tools 6" Stainless Steel Ruler, Machinist's Ruler, Round End Rule with Clip, 32nds-64ths of an inch, with Decimal Equivalent Chart on Back, Made in USA
4 NEIKO 01407A Electronic Digital Caliper Measuring Tool, 0 - 6 Inches Stainless Steel Construction with Large LCD Screen Quick Change Button for Inch Fraction Millimeter Conversions, Digital Caliper Measuring Tool

NEIKO 01407A Electronic Digital Caliper Measuring Tool, 0 - 6 Inches Stainless Steel Construction with Large LCD Screen Quick Change Button for Inch Fraction Millimeter Conversions, Digital Caliper Measuring Tool

  • QUICK-CHANGE MODES: SWITCH EASILY BETWEEN INCHES, FRACTIONS, & MM!
  • PRECISE MEASUREMENTS: ENJOY ACCURACY UP TO 0.001 FOR ALL NEEDS!
  • STURDY & VERSATILE: DURABLE DESIGN WITH EXTRA-LARGE LCD FOR EFFICIENCY!
BUY & SAVE
Save 15%
NEIKO 01407A Electronic Digital Caliper Measuring Tool, 0 - 6 Inches Stainless Steel Construction with Large LCD Screen Quick Change Button for Inch Fraction Millimeter Conversions, Digital Caliper Measuring Tool
5 Digital Caliper, HARDELL Caliper Measuring Tool 8 Inch/200mm, 0.001" High-Precision Stainless Steel Calipers with Easy Inch Fraction Millimeter Conversion, Auto-Off Caliper with Large LCD Screen

Digital Caliper, HARDELL Caliper Measuring Tool 8 Inch/200mm, 0.001" High-Precision Stainless Steel Calipers with Easy Inch Fraction Millimeter Conversion, Auto-Off Caliper with Large LCD Screen

  • ULTRA PRECISION MEASUREMENT: ACHIEVE ±0.001 ACCURACY WITH EASE!

  • CONVENIENT UNIT CONVERSION: SWITCH BETWEEN INCHES, MM, AND FRACTIONS INSTANTLY.

  • DURABLE DESIGN: RUST-RESISTANT STAINLESS STEEL FOR ANY MEASURING TASK.

BUY & SAVE
Save 50%
Digital Caliper, HARDELL Caliper Measuring Tool 8 Inch/200mm, 0.001" High-Precision Stainless Steel Calipers with Easy Inch Fraction Millimeter Conversion, Auto-Off Caliper with Large LCD Screen
6 ENGINEER Precision Mini Long Nose Pliers (Needle tip) 141mm Professional Grade ESD Safe with Carbon Steel Jaws. Made in Japan. PS-03

ENGINEER Precision Mini Long Nose Pliers (Needle tip) 141mm Professional Grade ESD Safe with Carbon Steel Jaws. Made in Japan. PS-03

  • PRECISION PLIERS: PERFECT FOR ELECTRONICS, CRAFTS, AND LAB WORK!
  • ESD SAFE GRIPS: COMFORT AND DURABILITY FOR EXTENDED USE.
  • SPRING-LOADED HANDLES: REDUCES HAND FATIGUE DURING REPETITIVE TASKS.
BUY & SAVE
ENGINEER Precision Mini Long Nose Pliers (Needle tip) 141mm Professional Grade ESD Safe with Carbon Steel Jaws. Made in Japan. PS-03
7 PEC Tools Metal Ruler, Machinist Rule with Satin Chrome Finish, Decimal/Metric Graduation (1/10", 1/100", 1mm, 0.5mm), 18"/450mm Flexible Steel Ruler, Trusted by Professionals, Made in USA

PEC Tools Metal Ruler, Machinist Rule with Satin Chrome Finish, Decimal/Metric Graduation (1/10", 1/100", 1mm, 0.5mm), 18"/450mm Flexible Steel Ruler, Trusted by Professionals, Made in USA

  • DURABLE TEMPERED STEEL ENSURES LONG-LASTING, RELIABLE PERFORMANCE.

  • FULL-FLEXIBILITY DESIGN FOR EASY MEASUREMENT OF CURVED SURFACES.

  • DUAL UNIT SCALES FOR SEAMLESS INCH AND METRIC CONVERSIONS.

BUY & SAVE
PEC Tools Metal Ruler, Machinist Rule with Satin Chrome Finish, Decimal/Metric Graduation (1/10", 1/100", 1mm, 0.5mm), 18"/450mm Flexible Steel Ruler, Trusted by Professionals, Made in USA
8 GODESON Metal Digital Tire Tread Depth Gauge, LCD Display Tire Tread Depth Gauge with 3 Modes-Fractional Inch, Decimal Inch and Millimeter,Precision Professional Measuring for Motorcycle, Car, Trucks

GODESON Metal Digital Tire Tread Depth Gauge, LCD Display Tire Tread Depth Gauge with 3 Modes-Fractional Inch, Decimal Inch and Millimeter,Precision Professional Measuring for Motorcycle, Car, Trucks

  • ACHIEVE <0.02MM ACCURACY FOR PRECISE TIRE TREAD MONITORING.
  • THREE MEASUREMENT MODES TO FIT ALL USER PREFERENCES SEAMLESSLY.
  • DURABLE METAL DESIGN ENSURES LONG-LASTING, RELIABLE PERFORMANCE.
BUY & SAVE
GODESON Metal Digital Tire Tread Depth Gauge, LCD Display Tire Tread Depth Gauge with 3 Modes-Fractional Inch, Decimal Inch and Millimeter,Precision Professional Measuring for Motorcycle, Car, Trucks
9 Performance Tool W131C Precision Feeler Gauge Set with 3-Inch Steel Rule - Decimal and Metric Sizes - SAE Sizes 002-025-Inch and Metric Sizes 05- 63 mm

Performance Tool W131C Precision Feeler Gauge Set with 3-Inch Steel Rule - Decimal and Metric Sizes - SAE Sizes 002-025-Inch and Metric Sizes 05- 63 mm

  • PRECISION MEASUREMENTS WITH BOTH DECIMAL AND METRIC SIZES!
  • BUILT TO LAST: DURABLE 3-INCH STEEL RULE WITHSTANDS FREQUENT USE.
  • VERSATILE TOOL FOR DIVERSE ENGINE SIZES: IDEAL FOR EVERY MECHANIC!
BUY & SAVE
Performance Tool W131C Precision Feeler Gauge Set with 3-Inch Steel Rule - Decimal and Metric Sizes - SAE Sizes 002-025-Inch and Metric Sizes 05- 63 mm
+
ONE MORE?

To get digits past the decimal in Elixir, you can use the Float.round/2 function along with the :precision option. This function rounds a float to a specified number of decimal places.

For example, if you have a float number and you want to get the digits up to 2 decimal places, you can use the following code:

rounded_number = Float.round(number, 2)

This will round the number to 2 decimal places and store it in the rounded_number variable. You can adjust the precision value as needed to get the desired number of decimal places.

How to get the integer part of a decimal number in Elixir?

You can get the integer part of a decimal number in Elixir by using the div function. Here's an example:

decimal_number = 5.67 integer_part = div(decimal_number, 1)

IO.puts integer_part # Output: 5

In this example, the div function is used to divide the decimal number by 1, which effectively removes the decimal part and leaves only the integer part.

How to convert decimal numbers to binary in Elixir?

Here's a simple implementation that converts a decimal number to binary in Elixir:

defmodule Converter do def decimal_to_binary(decimal) when is_integer(decimal) do decimal |> Integer.to_string(2) |> String.to_integer() end end

Converter.decimal_to_binary(10) # Output: 1010

You can use the Integer.to_string/2 function to convert the decimal number to a binary string representation, and then use String.to_integer/1 to convert the binary string back to an integer.

You can then call the decimal_to_binary function with the decimal number you want to convert to binary.

How to multiply decimal numbers in Elixir?

To multiply decimal numbers in Elixir, you can use the Kernel.* function. Here is an example:

num1 = Decimal.new("2.5") num2 = Decimal.new("1.5")

result = Kernel.*(num1, num2) IO.puts(result) # Output: 3.75

In this example, we are using the Decimal.new/1 function to create decimal numbers from strings, and then using the Kernel.* function to multiply the two decimal numbers together.

How to convert decimal numbers to integers in Elixir?

To convert decimal numbers to integers in Elixir, you can use the trunc/1, round/1, or floor/1 functions from the Float module. Here's an example using trunc/1:

decimal_number = 5.6 integer_number = trunc(decimal_number) IO.inspect(integer_number) # Output: 5

You can also use round/1 to round the decimal number to the nearest integer, or floor/1 to round down to the nearest integer.