Libre office Calc and Hour duration format? - libreoffice

I am so confused by the format Calc is expecting. I am former Numbers user(Apples version of Calc)
what am trying to achieve is to regard a cell that has a single digit as an hour and append "H" to the end.
For example, 3 will be reformatted to 3 H
Right now I am getting some weird calculations. I've tried applying
HH" H" to cell that has a single digit, it turns the cell into 00 H
HH" H" 22:33:22 22 H
HH" H" 221122 00 H
HH" H" 222 00 H
HH" H" 2 00 H
It keeps inserting 000s into the cell, the only one that gives me some result is the first one.
but having to type 22:33:22 for every cell is not ideal. Instead how can I get calc to just regard any digit as an hour?

Dates and times in spreadsheets are commonly stored as floating-point numbers, with 1.0 equal one day.
You can divide the value of the hour by 24 and format the result as time.
BTW, the format H" H" will give you single digit numbers if the value is less than 10.

Related

How can I print the ascii value of an input in Brainfuck?

What I want to do is for a Brainfuck code to print out the ascii value of the input. For example, typing in an input of "a" will give an output of 97. The python equivalent of this is print(ord(input())). What I'm thinking is that once I get the input with the , command, I can split the input value's digits into separate cells, and then print each cell individually. What I mean by this is let's say you type in an input of a. The , command will store the ascii value of a in the first cell(cell 0), which is 97 in this case. Then I run some algorithm that will split the 97 into its individual digits. So, in this case, cell 1 will have a value of 0(because 97 has a hundred digit of 0), cell 2 will have a value of 9, and cell 3 will have a value of 7. Then we can add 48 to each of those cells(0 has an ascii value of 48) and print each cell individually, starting from cell 1(the hundreds place). The problem I'm facing is writing the digit separation algorithm. I can't seem to make it work. My idea is to subtract 100 from the original number until that number is less than 100 while keeping track of how many times 100 has been subtracted, then repeatedly subtract 10, and finally we are left with the ones place. But the problem with this idea is that I have no idea how to track if the number falls under 100 or 10. Any suggestions or ideas? Thanks for the help in advance.
What you are trying to implement is called "divmod". divmod is a function that divides two numbers (in your case positive integers) and stores the result and the remainder. Implementations for this in brainfuck exist: Divmod algorithm in brainfuck
Good luck!

Reading and Writing some parts of a line in another text file in a preferred format in Matlab

I do appreciate any detailed helps. I really am in a terrible situation and I would be honored if anyone can help me with this issue in a great details! Thanks in advance!
Well! I have a large text file that is made of group of 209 rows! In another words in my large file there is simple element with the following format that repeats many times (let us name it NR) . each element has 209 rows and 5 columns. I am interested in having the data corresponding to the last three columns for 6 specific rows in each element. these 6 rows ( let me call them r1 to r6) are constant for all of the NR loops.
The third column which is the first column of interest starts at character number 25 of the row i.e. cell number 25 and ends at character number 37.
The forth column which is the second column of interest starts at character number 51 of the row i.e. cell number 51 and ends at 63.
The fifth column which is the third column of interest starts at character number 77 of the row i.e. cell number 77 and ends at 89.
I need to create NR separated text files and have the data of interest be written in the following format for each of the NR loop:
1) For each file the first 16 lines (rows) there is a similar text that is required to be at each file. For example :
"Thank you for your help!
I do appreciate it
and so on "
2) from Line 17 to Line 22 I need to print the data that has been read previously for r1 to r6 respectively, such a way that information of third column is being printed at character (cell) number 24, information of forth column is being printed at character (cell) number 40 and information of fifth column is being printed at character (cell) number 56.
3) for lines 17-22 I need to add four new columns at cells number , 4,8,12 and 16 respectively such that
A) the first column is 1 for r1, 2 for r2 and etc.
B) The second column is 1 for r1 and r2 and 2 for the r3 to r6
C) the third column is the same as second column
D) the forth column is always 0.
Wow! I know it might be so hard to get the point with the text :D
I hope you could help me with that !
So just to sum Up the points. I need NR separated files which names are from 1 to NR. Each of these NR files are related to the same loop in my large file.
Thanks!
All the best!

Converting a date/math formula in Excel into Numbers for Mac

I have a formula in Excel that subtracts a birth date from today's date and divides by 365 which gives the age in decimal format. Example below.
B4 is equal to birthday of 10/03/2011.
E4 is today's date.
The result is 2.73. My child is a little over 2 and 1/2.
=IF(B4>0,(E$4-B4)/365," ")
When I try to use this formula in Numbers for Mac, it gives me an error about comparing dates with numbers and so. I looked at DatedIF, TimeValue, and DateValue but couldn't figure out how to do it in Number.
Anyone know how I could get this formula to return a decimal value of 2.73 years of age?
Assuming B4 is in "date" format, you could try the following formula
=IF(ISBLANK(B4),"",YEARFRAC(B4,TODAY(),1))
Here is some documentation on YEARFRAC from the horse's mouth
Try entering the formula
=B4>0
in a different cell, you will then encounter en error
You can’t compare a date with a number because their data types are different.

How to convert a large number to base 36 using DC or other

I am trying to represent the maximum 64-bit unsigned value in different bases.
For base 2 (binary) it would be 64 1's:
1111111111111111111111111111111111111111111111111111111111111111
For base 16 (hex) it would be 16 F's
FFFFFFFFFFFFFFFF
For base 10 (decimal) it would be:
18446744073709551615
I'm trying to get the representation of this value in base 36 (it uses 0-9 and A-Z). There are many online base converters, but they all fail to produce the correct representation because they are limited by 64-bit math.
Does anyone know how to use DC (which is an extremely hard to use string math processors that can handle numbers of unlimited magnitude) and know how to do this conversion? Either that or can anyone tell me how I can perform this conversion with a calculator that won't fail due to integer roll-over?
I mad a quick test with ruby:
i = 'FFFFFFFFFFFFFFFF'.to_i(16)
puts i #18446744073709551615
puts i.to_s(36) #3w5e11264sgsf
You may also use larger numbers:
i = 'FFFFFFFFFFFFFFFF'.to_i(16) ** 16
puts i
puts i.to_s(36)
result:
179769313486231590617005494896502488139538923424507473845653439431848569886227202866765261632299351819569917639009010788373365912036255753178371299382143631760131695224907130882552454362167933328609537509415576609030163673758148226168953269623548572115351901405836315903312675793605327103910016259918212890625
1a1e4vngailcqaj6ud31s2kk9s94o3tyofvllrg4rx6mxa0pt2sc06ngjzleciz7lzgdt55aedc9x92w0w2gclhijdmj7le6osfi1w9gvybbfq04b6fm705brjo535po1axacun6f7013c4944wa7j0yyg93uzeknjphiegfat0ojki1g5pt5se1ylx93knpzbedn29
A short explanation what happens with big numbers:
Normal numbers are Fixnums. If you get larger numbers, the number becomes a Bignum:
small = 'FFFFFFF'.to_i(16)
big = 'FFFFFFFFFFFFFFFF'.to_i(16) ** 16
puts "%i is a %s" % [ small, small.class ]
puts "%i\n is a %s" % [ big, big.class ]
puts "%i^2 is a %s" % [ small, (small ** 2).class ]
Result:
268435455 is a Fixnum
179769313486231590617005494896502488139538923424507473845653439431848569886227202866765261632299351819569917639009010788373365912036255753178371299382143631760131695224907130882552454362167933328609537509415576609030163673758148226168953269623548572115351901405836315903312675793605327103910016259918212890625
is a Bignum
268435455^2 is a Bignum
From the documentation of Bignum:
Bignum objects hold integers outside the range of Fixnum. Bignum objects are created automatically when integer calculations would otherwise overflow a Fixnum. When a calculation involving Bignum objects returns a result that will fit in a Fixnum, the result is automatically converted.
It can be done with dc, but the output is not extremely useful.
$ dc
36
o
16
i
FFFFFFFFFFFFFFFF
p
03 32 05 14 01 01 02 06 04 28 16 28 15
Here's the explanation:
Entering a number by itself pushes that number
o pops the stack and sets the output radix.
i pops the stack and sets the input radix.
p prints the top number on the stack, in the current output radix. However, dc prints any output with a higher radix than 16 as binary (not ASCII).
In dc, the commands may be all put on the same line, like so:
$ dc
36o16iFFFFFFFFFFFFFFFFp
03 32 05 14 01 01 02 06 04 28 16 28 15
Get any language that can handle arbitrarily large integers. Ruby, Python, Haskell, you name it.
Implement the basic step: modulo 36 gives you the next digit, division by 36 gives you the number with the last digit cut out.
Map the digits to characters the way you like. For instance, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'[digit] is fine by me. Append digits to the result as you produce them.
???
Return the concatenated string of digits. Profit!

How does LLV encoding work?

I'm working with a binary protocol that uses LLV to encode some variables.
I was given an example below which is used to specify a set of 5 chars to display.
F1 F0 F5 4C 69 6E 65 31
the F1 is specific to my device, it indicates display text on line one. The f0 and f5 I'm not sure about, the rest looks like ASCII text.
Anyone know how this encoding works exactly?
LLV is referenced in this protocol spec. pasted below, but doesn't seem to be defined in there.
http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBIQFjAA&url=http%3A%2F%2Fwww.terminalhersteller.de%2FDownload%2FPA00P016_03_en.pdf&ei=yUFPTOSzH432tgON5PjuBw&usg=AFQjCNGjS_y264qKIRCSJQpdhlSXWtiadw&sig2=jMGtIwd42dozDSq7ub844w
Since the F1 is device-specific, this leaves the rest as F0 F5 ..., and this looks like an LLVAR sequence, in which the first two bytes specify the length of the rest (decimal 05 here). My guess would be that the whole data represents F1 "Line1", which looks quite reasonable.
By the way, LLVAR stands for "VARiable length with two decimal digits specifying the length". With three decimal digits for the length, it's LLLVAR.