class String
    def to_sci
        num = self
        num += '.0' unless num.include?('.')
        negative = num.slice!(0) if num[0] == '-'
        negative ||= false
        num.prepend('0') if num[0] == '.'
        raise "Must be a non-zero number I can turn into scientific notation" unless num.delete('1234567890-') == '.' && num =~ /\A(0[\.].*[1-9]|[1-9])/
        e = num.match(/((?<=0[\.])0*[1-9]|(?<=[1-9])\d*(?=[\.]))/)[0].length.to_s
        simple = num.delete('.').scan(/[1-9]\d*(?=0*)/)[0].insert(1,'.')
        simple.prepend('-') if negative #if the number's negative, add the proper sign
        e.prepend('-') if num =~ /\A-?0/ #it's negative sci-notation, so add a sign =)
        return "#{simple} x 10^#{e}"
    end
end
input = ''
    num = (rand(1509290) / rand(100).to_f).to_s
    num = input if input != ''
    puts "#{num}: #{num.to_sci}"    