What is the nPrecision parameter of RobotC displayLCDNumber? - robotics

Vex ROBOTC has the following command for displaying integers to the LCD display:
displayLCDNumber(nLine, nPos, nValue, nPrecision);
I'm trying to display the following: displayLCDNumber(0, 4, (float) 3.14159, nPrecision);
Supposedly, using the nPrecision parameter I should be able to display floats. Unfortunately, I cannot seem to get this to work. When I specify a negative integer, it just adds leading 0s to the displayed numbers. When I specify positive, it just shifts the integer portion of my number that many places right. When I try decimal nPrecisons such as 0.6, it does nothing. What is the nPrecision parameter and what do I need to set it too to correctly display my number?
API here: http://www.robotc.net/wikiarchive/VEX2_Functions_Display
Edit:
Any help would be apreciated, preferably as soon as possible because I will only get a chance to test/use it tomorrow and friday for like 30 minutes.

Related

How to get Google Sheets to recognize I'm entering time in MM:SS?

I am trying to record the time it takes for a number of things to occur, and can't seem to get Google Sheets to understand my input. I want to be able to type something like "26:30" into a cell, and have the spreadsheet understand that this means 26 minutes and 30 seconds, and then be able to use that number in formulas, e.g. to return the shortest of a series of times, or the difference between two times.
Also, the vast majority of the numbers I type in will be under an hour, so I don't want to have to type in something like "0:26:30" every time, just for it to understand that I mean 26 minutes, not 26 hours. However for the rare occasions where something is longer than an hour, I want to be able to be able to type something like "1:10:23" and not "70:23".
If possible, I would rather achieve this through directly formatting the cell I type the time into, rather than enter it in one format and have it converted in a separate cell via a formula.
Is there a way to do this that meets all of these goals?
google sheets is not designed in such a way. if you want to type in 26:30 then the best course of action is as follows:
convert cells to Plain Text, type in your duration, and account for your rules within formulae. to convert a text string into a value for the sake of calculation you can use the following principle
=ARRAYFORMULA(IFERROR(IF(REGEXMATCH(A1:A, ":\d+:"), A1:A*1, ("0:"&A1:A)*1)))
few examples:
=ARRAYFORMULA(TEXT(AVERAGE(IF(REGEXMATCH(A1:A2, ":\d+:"),
A1:A2*1, ("0:"&A1:A2)*1)), "[m]:ss"))
=ARRAYFORMULA(TEXT(SUM(IF(REGEXMATCH(A1:A2, ":\d+:"),
A1:A2*1, ("0:"&A1:A2)*1)), "[h]:mm:ss"))
=ARRAYFORMULA(TEXT(IF(REGEXMATCH(A2, ":\d+:"), A2*1, ("0:"&A2)*1)-
IF(REGEXMATCH(A1, ":\d+:"), A1*1, ("0:"&A1)*1), "[m]:ss"))
At this point in time there doesn't seem to be a way to directly format a cell such that Google Sheets recognises it as MM:SS instead of HH:MM, so I've had to go with formulas instead. Sharing the solution I used below.
I set it up so that the user entered the time into cell A1 in the form MM:SS or H:MM:SS and I formatted this cell as plain text, then had a second cell formatted as 'time duration' where it converted the input of A1 using the following formula:
=time(left(A1,if(len(A1)<6,"",len(A1)-6)),right(left(A1,len(A1)-3),2),right(A1,2))
To break this down:
It starts by assuming the contents of A1 is a text string with 5 or more characters in the form MM:SS or H:MM:SS or HH:MM:SS. It does not include any sort of error handling to check this is true.
The time(X,Y,Z) part of the formula converts different inputs into hours, minutes and seconds, respectively, and produces a number in the format HH:MM:SS, which is recognised as a time, and can therefore be used in formulas. Note that the cell has to be formatted as 'time duration' to display correctly.
In the above, Z is right(A1,2) which extracts the last two characters of A1, i.e. the SS part of the input. These end up as seconds.
Likewise, Y is right(left(A1,len(A1)-3),2) which extracts the 4th and 5th characters from the right of the text string of A1, i.e. the MM part of the input, after the :. This number is then recognised as minutes.
Finally, X is left(A1,if(len(A1)<6,"",len(A1)-6)), which basically says "if A1 is less than 6 characters then it must not have hours, so leave blank, otherwise extract out all characters except the last 6", i.e. the HH part of the input, if it exists. This number (which may or may not be 0) is then recognised as hours.

Is there a Function or set of functions on Google Sheets that reacts every multiple?

Okay, say I have 5 cells. Each with varying amounts.
I want a function that: If(Sum(b2:b6) {greater or equal to a multiple}, True, False
So every time the total value of those cells is greater to or equal to a multiple of, say 50, so if it lands on 50n+1 or something, it'll react as if it hit 50n.
I guess you are not multiplying but adding numbers in range, since you are using "SUM" in function. In case, here is a solution:
=IF((SUM(B2:B6))>=50;TRUE;FALSE)
Note: This code is written with Norwegian format settings. Change ";" in formula with "," for American format settings.
sounds like:
=IF(SUM(B2:B6)>=50; 50; )

Adding specific number at the end of a string until reach a specific total of characters

Example of values from my Column C:
https://www.betfair.com/exchange/plus/football/market/1.186894151
https://www.betfair.com/exchange/plus/football/market/1.186867498
https://www.betfair.com/exchange/plus/football/market/1.1869852
https://www.betfair.com/exchange/plus/football/market/1.186986585
https://www.betfair.com/exchange/plus/football/market/1.186986773
https://www.betfair.com/exchange/plus/football/market/1.18698631
https://www.betfair.com/exchange/plus/football/market/1.186971962
https://www.betfair.com/exchange/plus/football/market/1.18698667
https://www.betfair.com/exchange/plus/football/market/1.186973002
After the last / will always have the same amount of characters. But for some inexplicable reason the API is delivering the values without the zeros that exist to the right, so for example:
If the correct value is:
1.1011100
The value delivered is:
1.10111
So to adjust this I need to add the zeros to the right, for that I separate the last part of the value with this formula:
=ARRAYFORMULA(IF(C1:C="","",RIGHT(C1:C,LEN(C1:C)-FIND("*",SUBSTITUTE(C1:C,"/","*",LEN(C1:C)-LEN(SUBSTITUTE(C1:C,"/","")))))))
The result is:
1.186894151
1.186867498
1.1869852
1.186986585
1.186986773
1.18698631
1.186971962
1.18698667
1.186973002
And to calculate the maximum number of characters that can be found, I use:
=ARRAYFORMULA(MAX(LEN( FORMULA I PUT A LITTLE ABOVE IN QUESTION )))
The result in this case is 11, so in all values there must be 11 characters after the last slash.
But now I don't know how I can add the zeros numbers that are missing from each value so that the result is:
https://www.betfair.com/exchange/plus/football/market/1.186894151
https://www.betfair.com/exchange/plus/football/market/1.186867498
https://www.betfair.com/exchange/plus/football/market/1.186985200
https://www.betfair.com/exchange/plus/football/market/1.186986585
https://www.betfair.com/exchange/plus/football/market/1.186986773
https://www.betfair.com/exchange/plus/football/market/1.186986310
https://www.betfair.com/exchange/plus/football/market/1.186971962
https://www.betfair.com/exchange/plus/football/market/1.186986670
https://www.betfair.com/exchange/plus/football/market/1.186973002
What should I do to get this result?
Spreadsheet Link:
https://docs.google.com/spreadsheets/d/1PPnwwzFzN60G0rUjTgbBn5D5uIXaO-OTJtuHeKxCilw/edit?usp=sharing
I have provided you 2 methods in the spreadsheet.
LEN:
=ArrayFormula(IF(C1:C="",,C1:C&REPT("0",F1-LEN(E1:E))))
REGEXEXTRACT:
=ArrayFormula(IF(C1:C="",,REGEXEXTRACT(C1:C&REPT("0",F1),".+\/.{"&F1&"}")))

Pick the greatest number in a range that is also less than the corresponding number in another range's row

I have two sets of data in columns A and B. I would like to pick the maximum value from column A which is also less than the value in the corresponding row in column B. I think I ought to be able to do this with the MAXIFS function but all the examples I can find compare against static values. I tried these options
=MAXIFS(A1:A10, B1:B10, "<")
=MAXIFS(A1:A10, B1:B10, A&"<"&B)
but neither of them worked as expected. In the first case, it is always 0 suggesting the condition is never met, in the second it gives an error.
I know that I could do this by creating a separate region of cells which first filter out the data that doesn't match the conditional and then simply pick the max from what remains but I'd rather do it in a single cell if possible.
Is there a syntax for this comparison and, if so, what is it?
To the best of my knowledge there isn't a way of getting it to work with MAXIFS.
You can write this
=maxifs(A:A,A:A,"<"&B:B)
and it will accept it, but it just uses the first value in column B and doesn't do a side-by-side comparison.
So you have to do it another way e.g. with a combination of Max and If:
=ArrayFormula(max(if(A:A<B:B,A:A)))
or you can use max with a filter or query:
=max(filter(A:A,A:A<B:B))
=max(query(A:B,"select A where A<B"))
=ARRAY_CONSTRAIN(ARRAYFORMULA(
IF(LEN(INDIRECT(ADDRESS(ROW(), COLUMN(B:B))))>0,
IF(INDIRECT(ADDRESS(ROW(), COLUMN(B:B)))<MAX($A$1:$A),
MAX($A$1:$A), LARGE(UNIQUE($A$1:$A), 2)), )), 1, 1)

Google Sheets ARRAYFORUMLA that can show 0 if the value is less than or equal to zero. Otherwise show the value of that set of data

I have set of columns that I am attempting to calculate the combined total of those columns then subtract from that total 8, if the difference after 8 is equal to or less than 0 I want to only show zero in the column I am doing this formula in. For those who might ask, I am using the ARRAYFORUMLA cause I want this calculation to repeat as I add new rows, keeping the totals I am seeking on the same row as the calculation is being done onto. So far I have most of this working. Well up to the IF ELSE THEN type of portion. My attempt is/was
=if(LTE((B3:B)+(C3:C)-8,0),ARRAYFORMULA((B3:B)+(C3:C)), 0)
As long as I'm understanding you correctly, I believe this will work:
=if(lte(sum(B2:C)-8,0),0,sum(B2:C))
It's at the top of the row and sums columns B and C. You can add more columns easily this way by either changing B/C to something else or passing more columns in.
Sum-8 is greater than 0
Sum-8 is less than 0
If what you want to do is to add each row to the total but only if its sum is 8 or greater, then your original formula was nearly OK but the two parts of the IF statement should have been reversed
=sum(ArrayFormula(if(LTE((B3:B)+(C3:C)-8,0),0,(B3:B)+(C3:C))))
You could also take most of the brackets out
=sum(ArrayFormula(if(LTE(B3:B+C3:C-8,0),0,B3:B+C3:C)))
and this would also work
=sum(ArrayFormula(if(LTE(B3:B+C3:C,8),0,B3:B+C3:C)))
Short answer
ARRAYFORMULA that can show 0 if the value is less than or equal to zero. Otherwise show the value of that set of data:
=ArrayFormula(IF(LTE(A1:A3,0),0,A1:A3))
Explanation
The basic IF syntax requires the use of scalar values, to use it with arrays, ARRAYFORMULA is required as an outer function:
ARRAYFORMULA(IF(array_logical_expression,array_if_true,array_if_false))
For the specific case described on the body of the question, the corresponding formula is:
=ARRAYFORMULA(IF(LTE(B3:B+C3:C-8,0),0,B3:B+C3:C))
Reference
Google Docs editors Help
IF
ARRAYFORMULA
Using arrays in Google Sheets

Resources