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 November 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 MEASUREMENT SET: SAE & METRIC RULERS ENHANCE VERSATILITY FOR ALL TASKS.

  • QUICK CONVERSION: BUILT-IN TABLES SIMPLIFY UNIT CONVERSION FOR ACCURACY.

  • DURABLE & FUNCTIONAL: STAINLESS STEEL DESIGN ENSURES LONGEVITY AND RELIABILITY.

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.

  • PRECISE 1/32 & 1/64 SCALES ENSURE TOP-NOTCH ACCURACY.
  • DURABLE STEEL CONSTRUCTION GUARANTEES LONG-LASTING PRECISION.
  • LASER-ENGRAVED MARKINGS PROVIDE UNMATCHED CLARITY AND DURABILITY.
BUY & SAVE
$8.99 $9.99
Save 10%
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 General Tools Digital Caliper #147 - 6" Precision Measuring Tool - Stainless Steel Ruler

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

  • EXTRA LARGE LCD: QUICK SWITCH BETWEEN INCHES, FRACTIONS, AND MM.

  • DURABLE DESIGN: HEAVY-DUTY STAINLESS STEEL FOR LASTING PERFORMANCE.

  • BATTERY SAVER: AUTO POWER OFF FEATURE TO PROLONG BATTERY LIFE.

BUY & SAVE
$34.99 $48.60
Save 28%
General Tools Digital Caliper #147 - 6" Precision Measuring Tool - Stainless Steel Ruler
4 HARDELL Dial Caliper, Dual Reading Precision Caliper with Accuracy ±0.02", Durable Caliper Measuring Tool 6 Inch with Plastic Case, Lightweight Vernier Caliper for DIY/Household/Woodworking

HARDELL Dial Caliper, Dual Reading Precision Caliper with Accuracy ±0.02", Durable Caliper Measuring Tool 6 Inch with Plastic Case, Lightweight Vernier Caliper for DIY/Household/Woodworking

  • BATTERY-FREE PRECISION: ACHIEVE ±0.02 ACCURACY ANYTIME, ANYWHERE.

  • DUAL SCALE EFFICIENCY: QUICK DECIMAL & FRACTION READINGS, NO CONVERSIONS NEEDED.

  • VERSATILE 4-WAY MEASUREMENTS: ONE TOOL FOR ALL YOUR MEASUREMENT NEEDS.

BUY & SAVE
$9.99
HARDELL Dial Caliper, Dual Reading Precision Caliper with Accuracy ±0.02", Durable Caliper Measuring Tool 6 Inch with Plastic Case, Lightweight Vernier Caliper for DIY/Household/Woodworking
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

  • PRECISION MEASUREMENTS: DELIVERS ACCURATE DECIMAL AND METRIC SIZES FOR ADJUSTMENTS.

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

  • VERSATILE USE: IDEAL FOR CARS, MOTORCYCLES, AND SMALL ENGINES ALIKE.

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 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 PERFECT FOR ELECTRONICS AND LAB WORK.
  • ESD SAFE GRIPS ENSURE COMFORT DURING EXTENDED USE.
  • SPRING-LOADED HANDLES REDUCE HAND FATIGUE FOR REPEAT TASKS.
BUY & SAVE
$18.27
ENGINEER Compact Precision Compact Long Nose Pliers (Needle tip),Professional Grade, ESD Safe with Carbon Steel Jaws. Made in Japan. ps-03,Black,141mm
7 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 MODE SWITCHING: EFFORTLESSLY CONVERT BETWEEN INCH, FRACTION, AND MM!

  • PRECISION MEASUREMENTS: ACHIEVE ACCURACY UP TO 0.001” / 0.02 MM.

  • DURABLE DESIGN: SPLASH-RESISTANT, WITH A STURDY STAINLESS STEEL BODY.

BUY & SAVE
$27.99
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
8 HOPLEX 2PCS Precision Tweezers, Model Hobby Making Tools, Upgraded Bent and Straight Flat Tip Stainless Steel Tweezers for Gundam, Scale Military Model, 3D Resin Parts, Electronics, Sodlering, DIY

HOPLEX 2PCS Precision Tweezers, Model Hobby Making Tools, Upgraded Bent and Straight Flat Tip Stainless Steel Tweezers for Gundam, Scale Military Model, 3D Resin Parts, Electronics, Sodlering, DIY

  • VERSATILE FOR HOBBIES: PERFECT FOR MODELING, GUNDAM, AND 3D PARTS.

  • DURABLE STAINLESS STEEL: HIGH-STRENGTH RESISTANCE TO ACIDS AND CORROSION.

  • ERGONOMIC DESIGN: COMFORTABLE GRIP WITH ADJUSTABLE LOCKING FOR REDUCED FATIGUE.

BUY & SAVE
$9.99
HOPLEX 2PCS Precision Tweezers, Model Hobby Making Tools, Upgraded Bent and Straight Flat Tip Stainless Steel Tweezers for Gundam, Scale Military Model, 3D Resin Parts, Electronics, Sodlering, DIY
9 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

  • COMPACT DESIGN WITH FAST, ACCURATE READINGS FOR ULTIMATE CONVENIENCE.

  • MULTIPLE MEASUREMENT UNITS CATER TO DIVERSE WEIGHING NEEDS EFFORTLESSLY.

  • SMART-OFF AND OVERLOAD PROTECTION ENSURE RELIABILITY AND LONGEVITY.

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
+
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.