This site’s domain has changed from leaverou.me to lea.verou.me. Please update your bookmarks and links. Thanks!

Lea Verou

Life at the bleeding edge (of web standards)

Main menu

Skip to content
Feed
  • Home
  • CSS3 tools
  • Libraries
  • Press
  • Publications
  • Speaking
  • About me

Tag Archives: Math

Extend Math.log to allow for bases != e

Posted on March 26, 2009 by Lea Verou

As Math.log currently stands, it’s a bit useless. It only calculates natural logarithms (base e).  We can easily modify it however, to calculate logarithms of any base: Math.log = (function() { var log = Math.log; return function(n, a) { return log(n)/(a? log(a) : 1); } })(); We can now specify the base as a second [...]

Posted in Tips | Tagged JavaScript, Math | Leave a comment

Extend Math.round, Math.ceil and Math.floor to allow for precision

Posted on February 12, 2009 by Lea Verou

Math.round, Math.ceil and Math.floor are very useful functions. However, when using them, I find myself many times needing to specify a precision level. You don’t always want to round to an integer, you often just want to strip away some of the decimals. We probably all know that if we have a function to round [...]

Posted in Original | Tagged JavaScript, Math | 4 Comments

Social me

  • Follow me on twitter
  • My speaking on Lanyrd
  • View my slides on slideshare
  • Fork me on Github
  • My dribbble shots
  • View my designs on Flickr
  • Connect with me on LinkedIn
  • My traveling on dopplr
  • Music I like on last.fm

Ad packs

via Ad Packs

Recent comments

Powered by Disqus

Recent Posts

  • Exactly how much CSS3 does your browser support?
  • Why tabs are clearly superior
  • My new year’s resolution
  • What we still can’t do client-side
  • Dabblet blog
  • On web apps and their keyboard shortcuts
  • Introducing dabblet: An interactive CSS playground
  • Vendor prefixes have failed, what’s next?
  • Animatable: A CSS transitions gallery
  • My experience from Fronteers, JSConf EU, Frontend and FromTheFront

Tag cloud

bookmarklets border-radius box-shadow browser bugs browsers canvas CMYK colors conferences CSS CSS3 css3 gradients CSS3 properties CSS3 selectors CSS3 transitions CSS3 values CSS gradients CSS properties experiments feature detection forms gradient HTML HTML5 JavaScript JavaScript libraries jQuery Math MySQL Opera bugs patterns performance PHP regular expressions RGBA speaking standards SVG text-shadow twitter Unicode usability Vendor prefixes Webkit Webkit bugs

Categories

  • Apps & scripts (17)
  • Articles (17)
  • Benchmarks (2)
  • News (7)
  • Original (49)
  • Personal (21)
  • Rants (8)
  • Replies (4)
  • Speaking (6)
  • Thoughts (11)
  • Tips (25)

Blogroll

  • Christian Heilmann's blog
  • CSS Tricks
  • Estelle Weyl's blog
  • HTML5 doctor
  • Nice hotel at Petra, Lesvos, Greece
  • Nimbupani (Divya Manian's blog)
  • Quirksblog
  • Robert’s talk
  • Simurai
  • The CSS Ninja
Proudly powered by WordPress