05-05-2022 10:32 AM
"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?
Solved! Go to Solution.
05-05-2022 10:40 AM
Round To -Infinity
05-05-2022 10:48 AM
@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.
05-05-2022 11:00 AM - edited 05-05-2022 11:07 AM
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.)
05-05-2022 11:13 AM
05-05-2022 11:19 AM
... and if you really want DBL for some convoluted reason, you would just tell it the desired datatype.
05-05-2022 11:48 AM
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
05-05-2022 11:48 AM
Thanks everyone!!! you guys are awesome!
05-07-2022 10:49 AM
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
05-09-2022 02:23 AM
Why is it called "Round to -Infinity" anyway?
Why isn't it called Round down?