LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved!
Go to solution

"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?

GRCK5000_0-1651764635079.png

 

 

 

0 Kudos
Message 1 of 13
(1,509 Views)
Solution
Accepted by GRCK5000

Round To -Infinity


GCentral
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
(1,504 Views)
Solution
Accepted by GRCK5000

@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?

GRCK5000_0-1651764635079.png

 

 

 


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" billko_0-1651765629823.png node after converting the string to a fractional number.

Bill
CLD
(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
(1,501 Views)
Solution
Accepted by GRCK5000

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

 

altenbach_0-1651766846726.png

 

 

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

0 Kudos
Message 4 of 13
(1,487 Views)
Solution
Accepted by GRCK5000

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

 

altenbach_0-1651767174954.png

 

Message 5 of 13
(1,477 Views)
Solution
Accepted by GRCK5000

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

 

altenbach_0-1651767521362.png

 

 

Message 6 of 13
(1,469 Views)

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

0 Kudos
Message 7 of 13
(1,427 Views)

Thanks everyone!!! you guys are awesome!

0 Kudos
Message 8 of 13
(1,425 Views)

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

0 Kudos
Message 9 of 13
(1,321 Views)

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

Why isn't it called Round down?

0 Kudos
Message 10 of 13
(1,296 Views)