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 October 2025

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 RULERS FOR ACCURATE MEASUREMENTS IN SAE AND METRIC
  • QUICK MEASUREMENT CONVERSIONS WITH HANDY TABLES
  • DURABLE STAINLESS STEEL FOR LONG-LASTING USE ANYWHERE
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
2 PEC Tools 6“ Rigid Steel Ruler, Precision Stainless Steel Ruler, 1/32” and 1/64" Graduations on Front, Decimal Equivalent Chart on Back. Made in USA.

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

  • PRECISION: 720 SCALE ACCURACY FOR CRITICAL, HIGH-PRECISION MEASUREMENTS.
  • DURABILITY: HIGH-QUALITY STEEL ENSURES RIGIDITY AND RESISTS DEFORMATION.
  • CLARITY: LASER-ENGRAVED MARKINGS FOR ENHANCED READABILITY AND LONGEVITY.
BUY & SAVE
PEC Tools 6“ Rigid Steel Ruler, Precision Stainless Steel Ruler, 1/32” and 1/64" Graduations on Front, Decimal Equivalent Chart on Back. Made in USA.
3 ENGINEER Compact Precision Compact Long Nose Pliers (Needle tip),Professional Grade, ESD Safe with Carbon Steel Jaws. Made in Japan. ps-03,Black,141mm

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

  • PRECISION PLIERS FOR ELECTRONICS AND CRAFTS-PERFECT FOR ANY PROJECT!
  • ESD SAFE GRIPS ENSURE COMFORT AND SAFETY DURING USE.
  • SPRING-LOADED HANDLES REDUCE FATIGUE FOR EFFORTLESS, CONTINUOUS WORK.
BUY & SAVE
$18.35
ENGINEER Compact Precision Compact Long Nose Pliers (Needle tip),Professional Grade, ESD Safe with Carbon Steel Jaws. Made in Japan. ps-03,Black,141mm
4 1-6" STAINLESS STEEL POCKET PRECISION RULER READ IN ENGLISH 6THS DECIMAL 300/1

1-6" STAINLESS STEEL POCKET PRECISION RULER READ IN ENGLISH 6THS DECIMAL 300/1

  • DURABLE 6 STAINLESS STEEL FOR LONG-LASTING PRECISION!
  • EASY-TO-READ INCREMENTS: ENGLISH 6THS AND DECIMALS!
  • COMPACT DESIGN FITS PERFECTLY IN YOUR POCKET FOR CONVENIENCE!
BUY & SAVE
$7.18
1-6" STAINLESS STEEL POCKET PRECISION RULER READ IN ENGLISH 6THS DECIMAL 300/1
5 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

  • PRECISE MEASUREMENTS WITH BOTH DECIMAL AND METRIC SIZES.

  • DURABLE 3-INCH STEEL RULE FOR LONG-LASTING, FREQUENT USE.

  • WIDE SIZE RANGE FOR COMPATIBILITY WITH DIVERSE ENGINE TYPES.

BUY & SAVE
$7.49
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
6 ENGINEER PS-04 Compact Precision Compact Flat Nose, Long Nose Pliers, Professional Grade, ESD Safe with Carbon Steel Jaws

ENGINEER PS-04 Compact Precision Compact Flat Nose, Long Nose Pliers, Professional Grade, ESD Safe with Carbon Steel Jaws

  • LIGHTWEIGHT DESIGN IDEAL FOR PRECISE PCB AND ELECTRICAL TASKS.
  • DURABLE CARBON STEEL JAWS FOR SUPERIOR GRIP AND LONGEVITY.
  • ESD-SAFE HANDLES PROTECT AGAINST SHOCKS DURING SENSITIVE WORK.
BUY & SAVE
$18.12
ENGINEER PS-04 Compact Precision Compact Flat Nose, Long Nose Pliers, Professional Grade, ESD Safe with Carbon Steel Jaws
7 MAXUS Digital Pocket Gram Scale 500g x 0.01g High Precision with Tray, Weighs Small Food, Jewelry, Ounces, Grains, LCD Display, Tare Function

MAXUS Digital Pocket Gram Scale 500g x 0.01g High Precision with Tray, Weighs Small Food, Jewelry, Ounces, Grains, LCD Display, Tare Function

  • SMART-OFF AND OVERLOAD PROTECTION FOR RELIABLE, SAFE WEIGHING.
  • VERSATILE 6-UNIT MEASUREMENT FOR ALL YOUR WEIGHING NEEDS.
  • COMPACT, POCKET-SIZED DESIGN FOR ON-THE-GO CONVENIENCE.
BUY & SAVE
$8.99 $14.99
Save 40%
MAXUS Digital Pocket Gram Scale 500g x 0.01g High Precision with Tray, Weighs Small Food, Jewelry, Ounces, Grains, LCD Display, Tare Function
8 General Tools Digital Caliper #147 - 6" Precision Measuring Tool - Stainless Steel Ruler

General Tools Digital Caliper #147 - 6" Precision Measuring Tool - Stainless Steel Ruler

  • TRI-MODE DISPLAY: EASILY SWITCH BETWEEN INCHES, FRACTIONS, AND MM.

  • DURABLE DESIGN: HEAVY-DUTY STAINLESS STEEL ENSURES LONGEVITY AND PRECISION.

  • BATTERY EFFICIENT: AUTO POWER OFF FEATURE SAVES ENERGY FOR RELIABLE USE.

BUY & SAVE
$34.99 $48.60
Save 28%
General Tools Digital Caliper #147 - 6" Precision Measuring Tool - Stainless Steel Ruler
9 Helix - Combo Circle Plastic Drawing Template - Essential Drafting Tool for Precision Geometric Shapes - Ideal for Artists and Designers - Includes Various Circle Sizes

Helix - Combo Circle Plastic Drawing Template - Essential Drafting Tool for Precision Geometric Shapes - Ideal for Artists and Designers - Includes Various Circle Sizes

  • ENHANCE PRECISION WITH 45 CIRCLES IN VARIOUS SIZES AND MEASUREMENTS!
  • USER-FRIENDLY DESIGN INCLUDES CENTERING LINES FOR ACCURATE DRAWING.
  • DURABLE, FLEXIBLE PLASTIC PREVENTS SMUDGING FOR LONG-LASTING USE.
BUY & SAVE
$13.58 $15.95
Save 15%
Helix - Combo Circle Plastic Drawing Template - Essential Drafting Tool for Precision Geometric Shapes - Ideal for Artists and Designers - Includes Various Circle Sizes
+
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.