## How to create conditional logarithms in cells?

### How to create conditional logarithms in cells?

OS: Linux (gentoo, specifically)

Okay, I'm putting a spreadsheet together for a specifically musical application, and what I want to do is this:

I have a hypothetical value, that corresponds to a pitch. I want to find out what the closest octave of this value is to the standard pitch for tuning, which is 440 herz. To get octaves, we multiply or divide by 2. For example, say my value is 60 (maybe because I want to be in tune with electric current in the US, which runs at 60Hz). To get the closest value to 440Hz, I keep multiplying by 2, until I get 480Hz. I know that whatever value I seek will be between about 311Hz and 622Hz, as each of these are precicely one half-octave below and above 440 Herz, respectively.

In other words, I want to find x such that x=F*2^n, and 311=<x=<622. F is my starting value, and n is any integer. I want to output the value of x into a cell.

I suspect that it all has something to do with logarithms, perhaps the MROUND function, or maybe the IF function. Can anybody offer some advice?

Thanks,

EE
ExeecutorElassus

Posts: 1
Joined: Mon Dec 17, 2007 3:55 pm

### Re: How to create conditional logarithms in cells?

See if this works:
Code: Select all   Expand viewCollapse view
`x: =F/2^ROUND(LOG(F/440;2);0)`
Last edited by acknak on Tue Dec 18, 2007 8:41 pm, edited 1 time in total.
Reason: Slightly simpler formula
AOO4/LO5 • Linux • Fedora 23

acknak
Moderator

Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3