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 March 2026

1 PEC Tools 6 Inch Machinist Pocket Ruler - Stainless Steel Rigid Ruler, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back, Made in USA

PEC Tools 6 Inch Machinist Pocket Ruler - Stainless Steel Rigid Ruler, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back, Made in USA

  • ACHIEVE MAXIMUM PRECISION WITH 1/64 INCREMENTS FOR ACCURACY.
  • DURABLE, HIGH-QUALITY STEEL ENSURES LONG-LASTING, RIGID PERFORMANCE.
  • LASER-ENGRAVED MARKINGS PROVIDE CLARITY AND RESIST WEAR OVER TIME.
BUY & SAVE
$7.99 $9.99
Save 20%
PEC Tools 6 Inch Machinist Pocket Ruler - Stainless Steel Rigid Ruler, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back, Made in USA
2 PEC Tools 6" Machinist Pocket Ruler - Stainless Steel with Pocket Clip, Round End, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back - Made in USA

PEC Tools 6" Machinist Pocket Ruler - Stainless Steel with Pocket Clip, Round End, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back - Made in USA

  • ACCURATE MEASUREMENTS WITH 1/64 INCREMENTS FOR PRECISION WORK.
  • DURABLE STAINLESS STEEL DESIGN ENSURES LONGEVITY AND RELIABILITY.
  • CONVENIENT POCKET CLIP KEEPS RULER HANDY FOR QUICK ACCESS.
BUY & SAVE
$9.99 $10.99
Save 9%
PEC Tools 6" Machinist Pocket Ruler - Stainless Steel with Pocket Clip, Round End, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back - Made in USA
3 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 BETWEEN INCHES, FRACTIONS, AND MM EFFORTLESSLY.

  • PRECISION MEASUREMENT: ACCURATE READINGS WITH A RANGE OF 0”-6” & 0-150MM.

  • DURABLE DESIGN: SPLASH-RESISTANT STAINLESS STEEL WITH A LARGE LCD FOR CLARITY.

BUY & SAVE
$25.39 $27.99
Save 9%
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
4 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

  • ACHIEVE PRECISE MEASUREMENTS WITH SAE & METRIC RULERS INCLUDED.
  • QUICK CONVERSIONS AT YOUR FINGERTIPS WITH HANDY CONVERSION TABLES.
  • DURABLE STAINLESS STEEL DESIGN PERFECT FOR ANY PROFESSIONAL TASK.
BUY & SAVE
$6.49 $7.00
Save 7%
SE Stainless Steel SAE Metric Ruler Set - Stainless Steel Precision Ruler Measuring Tool - Detachable Clips - Set of 2 Pcs - 925PSR-2
5 PEC Tools 6” Machinist Pocket Ruler – 3 Pack Bundle, Stainless Steel with Pocket Clip, Round End, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back, Made in USA

PEC Tools 6” Machinist Pocket Ruler – 3 Pack Bundle, Stainless Steel with Pocket Clip, Round End, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back, Made in USA

  • TRIPLE THE VALUE: GET 3 POCKET RULERS FOR LESS THAN 2 SINGLES!

  • VERSATILE MEASURES: FLEXIBLE STEEL FOR DEPTH, HEIGHT, AND TIGHT SPACES.

  • AMERICAN QUALITY: TRUSTED SINCE 1960, BUILT FOR DURABILITY AND PRECISION.

BUY & SAVE
$24.99
PEC Tools 6” Machinist Pocket Ruler – 3 Pack Bundle, Stainless Steel with Pocket Clip, Round End, 32nds and 64ths Graduations on Front, Decimal Equivalents Chart on Back, Made in USA
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 WITH FINE NEEDLE NOSE FOR INTRICATE TASKS.
  • ESD-SAFE GRIPS ENSURE COMFORT DURING LONG PROJECTS.
  • SPRING-LOADED HANDLES REDUCE HAND FATIGUE FOR EFFICIENT WORK.
BUY & SAVE
$18.18
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

  • FULL-FLEXIBLE DESIGN: EASILY MEASURES CURVED SURFACES AND TIGHT SPACES.
  • DUAL MEASUREMENT UNITS: SEAMLESSLY SWITCH BETWEEN INCH AND METRIC SCALES.
  • DURABLE STEEL CONSTRUCTION: BUILT TO LAST THROUGH HARD HITS AND DROPS.
BUY & SAVE
$28.99
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 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: OFFERS DECIMAL AND METRIC SIZES FOR ACCURATE ADJUSTMENTS.

  • BUILT TO LAST: DURABLE 3-INCH STEEL RULE WITHSTANDS FREQUENT TOOLBOX USE.

  • VERSATILE COMPATIBILITY: WORKS ON CARS, MOTORCYCLES, AND SMALL ENGINES.

BUY & SAVE
$6.40 $7.95
Save 19%
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
9 PEC Tools 12"/300mm Flexible Metal Ruler, High-Quality Steel Machinist Rule with Satin Chrome Finish, Decimal/Metric Graduation (1/10", 1/100", 1mm, 0.5mm), Trusted by Professionals, Made in USA

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

  • DUAL MEASUREMENT UNITS: EASILY SWITCH BETWEEN INCHES AND MILLIMETERS.

  • DURABLE DESIGN: ETCHED GRADUATIONS WITH SATIN CHROME FINISH RESIST WEAR.

  • FLEXIBLE & PRECISE: CONFORMS TO CURVES FOR ACCURATE MEASUREMENTS IN TIGHT SPACES.

BUY & SAVE
$16.99 $27.99
Save 39%
PEC Tools 12"/300mm Flexible Metal Ruler, High-Quality Steel Machinist Rule with Satin Chrome Finish, Decimal/Metric Graduation (1/10", 1/100", 1mm, 0.5mm), Trusted by Professionals, Made in USA
+
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.