# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Does anyone know a block that I can use to round numbers down?

"Number to Fractional string" is not really working for me. It keeps rounding it up to the nearest integer.

So I have these following numbers being

0.4181

3.5029

6.5877

9.6725

12.7573

15.6237

18.9200

22.0000

25.000

I would like to round the above numbers to these integers:

0

3

6

9

12

15

18

22

25

I tried using these blocks below. They were not helpful at all. Does anyone have an idea what I should use?

Message 1 of 13
(946 Views)
Solution
Accepted by topic author GRCK5000

## Re: Does anyone know a block that I can use to round numbers down?

Round To -Infinity

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 13
(941 Views)
Solution
Accepted by topic author GRCK5000

## Re: Does anyone know a block that I can use to round numbers down?

@GRCK5000 wrote:

"Number to Fractional string" is not really working for me. It keeps rounding it up to the nearest integer.

So I have these following numbers being

0.4181

3.5029

6.5877

9.6725

12.7573

15.6237

18.9200

22.0000

25.000

I would like to round the above numbers to these integers:

0

3

6

9

12

15

18

22

25

I tried using these blocks below. They were not helpful at all. Does anyone have an idea what I should use?

So I am assuming you are getting a string that represents a number, and you're trying to round it down (truncate) to the nearest integer?  Number to fractional string does NOT round to the nearest integer.  (Maybe you are mistaking it for "Number To Decimal String"?)

Anyway, the proper node you are looking for is the "Round Toward -Infinity" node after converting the string to a fractional number.

Bill

(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 13
(938 Views)
Solution
Accepted by topic author GRCK5000

## Re: Does anyone know a block that I can use to round numbers down?

Apparently, you have formatted strings, not numerics. If you want to keep it as strings, just truncate at the period using string functions.

As you probably noticed, the quality of the answers can typically not exceed the quality of the questions. Next time attach a simple VI that contains some typical inputs as diagram constants, then explain exactly what output you want (string, DBL, integer, etc., etc.)

Message 4 of 13
(924 Views)
Solution
Accepted by topic author GRCK5000

## Re: Does anyone know a block that I can use to round numbers down?

... and if you want numeric integers, things are even simpler:

Message 5 of 13
(914 Views)
Solution
Accepted by topic author GRCK5000

## Re: Does anyone know a block that I can use to round numbers down?

... and if you really want DBL for some convoluted reason, you would just tell it the desired datatype.

Message 6 of 13
(906 Views)

## Re: Does anyone know a block that I can use to round numbers down?

You have many ways to get things done. I'll definitely need all these in the future. You never know when these may be neede

Message 7 of 13
(864 Views)

## Re: Does anyone know a block that I can use to round numbers down?

Thanks everyone!!! you guys are awesome!

Message 8 of 13
(862 Views)

## Re: Does anyone know a block that I can use to round numbers down?

GRCK5000 -- When are you going to invest the time to educate yourself about LabVIEW?  There are books that will teach you (yes, you'll have to read a bit, think a bit, maybe even try out some of the functions and ideas that are presented, but things that you learn on your own, with your own efforts, tend to "stick" with you the longest.

Despite the efforts of a number of the participants in this Forum to get you to put a little effort into your learning, including repeated attempts to get you to include your code examples when you ask a simple "newbie" question such as "Does anyone know a block that I can use to round numbers down?", you persist in asking these questions, without attaching your code.

Here is a different suggestion.

Suppose you want to know where to find "a block that I can use to round numbers down".  When I mentor LabVIEW users, I often say "concentrate on what you want to do , not on how you are going to do it".  Your "What" is "round a number" -- you are doing something with a number.  I trust you have looked at the Function Palettes on the Block Diagram, and noticed there is one called "Numerics" -- maybe it has something to do with Numbers.  Open it up.  Look at the names of the Functions.  Look at the Icons for each of them.  If you have had a College math course, you might have been introduced to the "Floor" and "Ceiling" functions, which round down (Floor) and up (Ceiling) to the nearest integer.   The symbols for these two functions are on the two functions in the Palette called "Round toward -Infinity" and "Round towards +Infinity".

To really learn about these functions, use LabVIEW to write yourself a little Demo routine,  Try it out.  See how it works.  What do these functions do to 4.5 (exactly midway between)?  [Note -- I honestly don't know, but I am pretty sure I could figure it out, if I thought it was important ...].

Please give us all a break -- do more of your own work, spend more of your time learning, and when you really do need some help, provide your work by attaching your VI(s).

Bob Schor

Message 9 of 13
(758 Views)

## Re: Does anyone know a block that I can use to round numbers down?

Why is it called "Round to -Infinity" anyway?

Why isn't it called Round down?

Message 10 of 13
(733 Views)