我正在学习浮点数的算法.我写了下面的代码.但是不会发生浮点异常.我的环境是Cent OS 6.4(x86_64).
请教我这个理由.
#include <stdio.h>
int
main(void)
{
double a,b,c;
unsigned short int fctr;
a=3.0;
b=0.0;
c=1.0;
asm volatile(
"fstcw %w0" // get FPU control word
:"=m"(fctr):);
printf("FPU control word= %X\n", fctr);
fctr = fctr ^ 0x4;
printf("FPU control word= %X\n", fctr);
asm volatile(
"fldcw %w0" // set operand to FPU control word
: :"m"(fctr));
asm volatile(
"fstcw %w0" // get FPU control word
:"=m"(fctr):);
printf("FPU control word= %X\n", fctr);
c = a/b;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我试图通过简单的快速代码使用iOS模拟器获得位置.但是在调试会话中,不会调用回调函数.我将虚拟位置设置为iOS模拟器.
// ViewController.swift
// helloWorld
//
// Created by on 5/17/15.
// Copyright (c) 2015 All rights reserved.
//
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locMan: CLLocationManager!
var lat: CLLocationDegrees!
var lng: CLLocationDegrees!
var hasPosData: Bool
required init(coder aDecoder: NSCoder) {
locMan = CLLocationManager()
lat = CLLocationDegrees()
lng = CLLocationDegrees()
hasPosData = false
super.init(coder: aDecoder)
}
func retreiveCurrentPos(){
locMan.delegate = self
locMan.requestAlwaysAuthorization()
// start using GPS function
locMan.startUpdatingLocation()
}
func saveResult2File(){
var contents: String
let dirToSave …Run Code Online (Sandbox Code Playgroud)